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.
This commit is contained in:
Yuriy M. Kaminskiy
2015-08-04 16:51:53 +01:00
committed by Nick Clifton
parent 4e13f8fb05
commit 7e27a9d5f2
5 changed files with 28 additions and 5 deletions

View File

@@ -14467,7 +14467,7 @@ process_mips_specific (FILE * file)
len = sizeof (* eopt);
while (len < option->size)
{
char datum = * ((char *) eopt + offset + len);
unsigned char datum = * ((unsigned char *) eopt + offset + len);
if (ISPRINT (datum))
printf ("%c", datum);