From 7e0d77ef5ffa7e47655db2a5df5082004f7c104e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 14 Jan 2021 09:15:13 +0000 Subject: [PATCH] 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. --- bfd/ChangeLog | 4 ++++ bfd/elf.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 330b0d7af47..7f1b720b94f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2021-01-14 Nick Clifton + + * elf.c (elfcore_grok_win32pstatus): Check for a note type of 0. + 2021-01-13 Alan Modra * Makefile.in: Regenerate. 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) -- 2.30.2