This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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 PR gas/7025, another uninitialized read


When reading from a macro (the "scrubbed" expansion) it might
end without an end-of-line character, for example the last .endm
line in macros/dot.s, and the position beyond the end then has
undefined contents.  This mismatches with several places calling
find_end_of_line (_find_end_of_line), which doesn't have a limit
check, instead assuming that there's an end-of-line character at
the end of the line.  While I *could* change the ABI of that
function to properly pass a limit to check for, it seems better
to just put a "stop"-character there, in code that is much less
likely to be on any assembly hot-path, on the assumption that
.macro expansion is rare, certainly so in asm-less gcc-generated
code.

Fixes the problem, no valgrind complaints for this test for
neither cris-axis-elf nor arm-unknown-linux-gnu and no
regressions running the gas testsuite.  Port-specific FAILs with
valgrind-checking remain though.

Ok to commit?

gas:
	PR gas/7025
	* input-scrub.c (input_scrub_include_sb): Make the position
	after the input have defined contents, a 0 character.

Index: input-scrub.c
===================================================================
RCS file: /cvs/src/src/gas/input-scrub.c,v
retrieving revision 1.19
diff -p -u -r1.19 input-scrub.c
--- input-scrub.c	3 Jul 2007 11:01:03 -0000	1.19
+++ input-scrub.c	12 Nov 2008 02:05:43 -0000
@@ -283,6 +283,12 @@ input_scrub_include_sb (sb *from, char *
       sb_add_char (&from_sb, '\n');
     }
   sb_scrub_and_add_sb (&from_sb, from);
+
+  /* Make sure the parser looks at defined contents when it scans for
+     e.g. end-of-line at the end of a macro.  */
+  sb_add_char (&from_sb, 0);
+  from_sb.len--;
+
   sb_index = 1;
 
   /* These variables are reset by input_scrub_push.  Restore them

brgds, H-P


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