This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][PR gdb/16013] Fix off-by-one errors in *scanf format strings


Hi all,

This patch fixes a number of off-by-one errors in *scanf format
strings.

Ok to commit?

Thanks,
Gary

-- 
http://gbenson.net/


2013-10-14  Gary Benson  <gbenson@redhat.com>

	PR 16013
	* common/linux-osdata.c (command_from_pid): Fix off-by-one error
	in fscanf format string.
	(print_sockets): Fix off-by-one error in sscanf format string.
	(linux_xfer_osdata_modules): Likewise.

diff --git a/gdb/common/linux-osdata.c b/gdb/common/linux-osdata.c
index 9723839..8ebbab8 100644
--- a/gdb/common/linux-osdata.c
+++ b/gdb/common/linux-osdata.c
@@ -137,7 +137,7 @@ command_from_pid (char *command, int maxlen, PID_T pid)
 	 (for the brackets).  */
       char cmd[32]; 
       PID_T stat_pid;
-      int items_read = fscanf (fp, "%lld %32s", &stat_pid, cmd);
+      int items_read = fscanf (fp, "%lld %31s", &stat_pid, cmd);
 	  
       if (items_read == 2 && pid == stat_pid)
 	{
@@ -880,7 +880,7 @@ print_sockets (unsigned short family, int tcp, struct buffer *buffer)
 	      int result;
 
 	      result = sscanf (buf,
-			       "%d: %33[0-9A-F]:%X %33[0-9A-F]:%X %X %X:%X %X:%lX %X %d %d %lu %512s\n",
+			       "%d: %33[0-9A-F]:%X %33[0-9A-F]:%X %X %X:%X %X:%lX %X %d %d %lu %511s\n",
 			       &sl,
 			       local_address, &local_port,
 			       remote_address, &remote_port,
@@ -1471,7 +1471,7 @@ linux_xfer_osdata_modules (gdb_byte *readbuf,
 		  int items_read;
 		  
 		  items_read = sscanf (buf,
-				       "%64s %d %d %256s %16s 0x%llx",
+				       "%63s %d %d %255s %15s 0x%llx",
 				       name, &size, &uses,
 				       dependencies, status, &address);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]