summaryrefslogtreecommitdiff
path: root/bfd/tekhex.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-06-26 15:46:34 +0100
committerNick Clifton <nickc@redhat.com>2017-06-26 15:46:34 +0100
commit04e15b4a9462cb1ae819e878a6009829aab8020b (patch)
treeed016304b7a644f46639368257347dc0dc7b3752 /bfd/tekhex.c
parentcfd14a500e0485374596234de4db10e88ebc7618 (diff)
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.
Diffstat (limited to 'bfd/tekhex.c')
-rw-r--r--bfd/tekhex.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 214b54a817..cfa75d53c8 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 '%'. */