This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix PR gas/7025, another uninitialized read
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sourceware dot org
- Date: Wed, 12 Nov 2008 03:12:27 +0100
- Subject: 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