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]

Fix off-by-one in add-symbol-file


We should extend sect_opts _before_ it overflows. :-)
Checked in as obvious.

Andreas.

2006-08-24  Andreas Schwab  <schwab@suse.de>

	* symfile.c (add_symbol_file_command): Fix off-by-one when
	extending sect_opts.

--- gdb/symfile.c.~1.175.~	2006-08-16 10:50:13.000000000 +0200
+++ gdb/symfile.c	2006-08-24 14:13:42.000000000 +0200
@@ -1853,7 +1853,7 @@ add_symbol_file_command (char *args, int
                to load the program. */
 	    sect_opts[section_index].name = ".text";
 	    sect_opts[section_index].value = arg;
-	    if (++section_index > num_sect_opts)
+	    if (++section_index >= num_sect_opts)
 	      {
 		num_sect_opts *= 2;
 		sect_opts = ((struct sect_opt *)
@@ -1889,7 +1889,7 @@ add_symbol_file_command (char *args, int
 		    {
 		      sect_opts[section_index].value = arg;
 		      expecting_sec_addr = 0;
-		      if (++section_index > num_sect_opts)
+		      if (++section_index >= num_sect_opts)
 			{
 			  num_sect_opts *= 2;
 			  sect_opts = ((struct sect_opt *)

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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