From: Nick Clifton Date: Mon, 26 Jun 2017 14:46:34 +0000 (+0100) Subject: Fix address violation parsing a corrupt texhex format file. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04e15b4a9462cb1ae819e878a6009829aab8020b;p=binutils-gdb.git Fix address violation parsing a corrupt texhex format file. PR binutils/21670 * tekhex.c (getvalue): Check for the source pointer exceeding the end pointer before the first byte is read. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8a4352f4944..6cf71c32a2f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-06-26 Nick Clifton + + PR binutils/21670 + * tekhex.c (getvalue): Check for the source pointer exceeding the + end pointer before the first byte is read. + 2017-06-26 Nick Clifton PR binutils/21665 diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 214b54a8177..cfa75d53c87 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -273,6 +273,9 @@ getvalue (char **srcp, bfd_vma *valuep, char * endp) bfd_vma value = 0; unsigned int len; + if (src >= endp) + return FALSE; + if (!ISHEX (*src)) return FALSE; @@ -514,9 +517,10 @@ pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *, char *)) /* To the front of the file. */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return FALSE; + while (! is_eof) { - char src[MAXCHUNK]; + static char src[MAXCHUNK]; char type; /* Find first '%'. */