public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][PR gdb/16013] Fix off-by-one errors in *scanf format strings
@ 2013-10-14 10:52 Gary Benson
  2013-10-14 11:25 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Gary Benson @ 2013-10-14 10:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: dcb314

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);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-18 16:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14 10:52 [PATCH][PR gdb/16013] Fix off-by-one errors in *scanf format strings Gary Benson
2013-10-14 11:25 ` Pedro Alves
2013-10-18 14:39   ` [PATCH v2][PR " Gary Benson
2013-10-18 16:38     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).