[PATCH 6/5] Only warn about malformed win32pstatus notes
Jon Turney
jon.turney@dronecode.org.uk
Sat Aug 22 14:17:44 GMT 2020
On 21/07/2020 14:15, Jon Turney wrote:
> bfd/ChangeLog:
>
> 2020-07-21 Jon Turney <jon.turney@dronecode.org.uk>
>
> * elf.c (elfcore_grok_win32pstatus): Warn on malformed
> win32pstatus notes, and return TRUE so we continue rather than
> stopping as if it was an error.
> ---
> bfd/ChangeLog | 6 ++++++
> bfd/elf.c | 39 ++++++++++++++++++++++++++-------------
> 2 files changed, 32 insertions(+), 13 deletions(-)
>
> diff --git a/bfd/elf.c b/bfd/elf.c
> index b836f041724..f28b553b67b 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
[...]> if (note->descsz < 12 + name_size)
> - return FALSE;
> + {
> + _bfd_error_handler (_("%pB: win32pstatus NOTE_INFO_MODULE of size %lu is too small to contain a name of size %zu"),
> + abfd, note->descsz, name_size);
> + return TRUE;
> + }
As reported at [1], using '%zu' here is incorrect, as it's not handled
by _bfd_error_handler().
I propose to apply the attached as obvious.
[1] https://sourceware.org/pipermail/gdb-patches/2020-August/171391.html
-------------- next part --------------
From c261718f3cebf280f9088433f34793428f9c455a Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Fri, 21 Aug 2020 16:30:00 +0100
Subject: [PATCH] Fix erroroneous use of '%zu' in elfcore_grok_win32pstatus
As reported in [1], _bfd_error_handler() doesn't support '%zu'.
module_name_size is always 32-bits in the data structure we are
extracting it from, so use an unsigned int to store it instead.
[1] https://sourceware.org/pipermail/gdb-patches/2020-August/171391.html
bfd/ChangeLog:
2020-08-21 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Change name_size to unsigned
int. Use '%u' format with _bfd_error_handler to render it.
---
bfd/ChangeLog | 5 +++++
bfd/elf.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index ecd9217b34d..f32118ad404 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10140,7 +10140,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
char buf[30];
char *name;
size_t len;
- size_t name_size;
+ unsigned int name_size;
asection *sect;
unsigned int type;
int is_active_thread;
@@ -10248,7 +10248,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
if (note->descsz < 12 + name_size)
{
- _bfd_error_handler (_("%pB: win32pstatus NOTE_INFO_MODULE of size %lu is too small to contain a name of size %zu"),
+ _bfd_error_handler (_("%pB: win32pstatus NOTE_INFO_MODULE of size %lu is too small to contain a name of size %u"),
abfd, note->descsz, name_size);
return TRUE;
}
--
2.28.0
More information about the Binutils
mailing list