From 7e27a9d5f22f9f7ead11738b1546d0b5c737266b Mon Sep 17 00:00:00 2001 From: "Yuriy M. Kaminskiy" Date: Tue, 4 Aug 2015 16:51:53 +0100 Subject: Fix stack buffer overflows when parsing corrupt ihex files. PR binutils/18750 * ihex.c (ihex_scan): Fixes incorrect escape sequence in error message and stack overflow when char is signed and \200-\376 was in place of hex digit; also fixes \377 was handled as EOF instead of "incorrect character". (ihex_read_section): Changed for consistency. (ihex_bad_byte): Prevent (now impossible to trigger) stack overflow and incorrect escape sequence handling. * srec.c (srec_bad_byte): Likewise. * readelf.c (process_mips_specific): Fix incorrect escape sequence handling. --- bfd/srec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bfd/srec.c') diff --git a/bfd/srec.c b/bfd/srec.c index 24573cf..96b6a2f 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -249,7 +249,7 @@ srec_bad_byte (bfd *abfd, char buf[40]; if (! ISPRINT (c)) - sprintf (buf, "\\%03o", (unsigned int) c); + sprintf (buf, "\\%03o", (unsigned int) c & 0xff); else { buf[0] = c; -- cgit v1.1