Fix buffer overrun parsing a corrupt tekhex binary.

PR binutils/21962
	* tekhex.c (getsym): Fix check for source pointer walking off the
	end of the input buffer.
This commit is contained in:
Nick Clifton 2017-08-18 08:45:12 +01:00
parent dd66b39984
commit de25939739
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2017-08-18 Nick Clifton <nickc@redhat.com>
PR binutils/21962
* tekhex.c (getsym): Fix check for source pointer walking off the
end of the input buffer.
2017-08-17 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/18808

View File

@ -307,7 +307,7 @@ getsym (char *dstp, char **srcp, unsigned int *lenp, char * endp)
len = hex_value (*src++);
if (len == 0)
len = 16;
for (i = 0; i < len && src < endp; i++)
for (i = 0; i < len && (src + i) < endp; i++)
dstp[i] = src[i];
dstp[i] = 0;
*srcp = src + i;