* [PATCH] readelf: Handle NULL shdr in section_name
@ 2023-04-06 15:04 Mark Wielaard
2023-04-14 15:26 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2023-04-06 15:04 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
In some error cases we want to show the section name but cannot
because the section header is corrupt or NULL. Make sure the
section_name always returns "???" in that case.
* src/readelf.c (section_name): Check for shdr == NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/readelf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/readelf.c b/src/readelf.c
index 6950204e..4a1b985d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1606,7 +1606,7 @@ static const char *
section_name (Ebl *ebl, GElf_Shdr *shdr)
{
size_t shstrndx;
- if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
+ if (shdr == NULL || elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
return "???";
return elf_strptr (ebl->elf, shstrndx, shdr->sh_name) ?: "???";
}
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] readelf: Handle NULL shdr in section_name
2023-04-06 15:04 [PATCH] readelf: Handle NULL shdr in section_name Mark Wielaard
@ 2023-04-14 15:26 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2023-04-14 15:26 UTC (permalink / raw)
To: elfutils-devel
Hi,
On Thu, 2023-04-06 at 17:04 +0200, Mark Wielaard wrote:
> In some error cases we want to show the section name but cannot
> because the section header is corrupt or NULL. Make sure the
> section_name always returns "???" in that case.
>
> * src/readelf.c (section_name): Check for shdr == NULL.
Pushed,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-14 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 15:04 [PATCH] readelf: Handle NULL shdr in section_name Mark Wielaard
2023-04-14 15:26 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).