aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-01-14 09:16:58 +0000
committerNick Clifton <nickc@redhat.com>2021-01-14 09:16:58 +0000
commit5dda6736c275d6973cdeaec1d17edec55dcbad35 (patch)
tree5578e615a9acb70f8d0ac050ed87bce5abfa2bf4
parentAutomatic date update in version.in (diff)
downloadbinutils-gdb-5dda6736c275d6973cdeaec1d17edec55dcbad35.tar.gz
binutils-gdb-5dda6736c275d6973cdeaec1d17edec55dcbad35.tar.bz2
binutils-gdb-5dda6736c275d6973cdeaec1d17edec55dcbad35.zip
Fix an illegal memory access parsing a win32pstatus note with a type of 0.
* elf.c (elfcore_grok_win32pstatus): Check for a note type of 0.
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5598539d8d0..029d8ff807e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2021-01-14 Nick Clifton <nickc@redhat.com>
+
+ * elf.c (elfcore_grok_win32pstatus): Check for a note type of 0.
+
2021-01-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/27171
diff --git a/bfd/elf.c b/bfd/elf.c
index ab19bdb4530..84a5d942817 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10163,7 +10163,8 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
type = bfd_get_32 (abfd, note->descdata);
- struct {
+ struct
+ {
const char *type_name;
unsigned long min_size;
} size_check[] =
@@ -10174,7 +10175,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
{ "NOTE_INFO_MODULE64", 16 },
};
- if (type > (sizeof(size_check)/sizeof(size_check[0])))
+ if (type == 0 || type > (sizeof(size_check)/sizeof(size_check[0])))
return TRUE;
if (note->descsz < size_check[type - 1].min_size)