* [PATCH] sepdebugcrcfix: Don't crash if .gnu_debuglink doesn't contain a file string.
@ 2021-07-01 14:15 Mark Wielaard
0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2021-07-01 14:15 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
If the .gnu_debuglink section didn't contain a valid file string then we would crash.
Produce an error instead.
* tools/sepdebugcrcfix.c (process): Produce an error when zerop is NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tools/sepdebugcrcfix.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/sepdebugcrcfix.c b/tools/sepdebugcrcfix.c
index 20800ba..024d09c 100644
--- a/tools/sepdebugcrcfix.c
+++ b/tools/sepdebugcrcfix.c
@@ -258,10 +258,13 @@ process (Elf *elf, int fd, const char *fname)
continue;
}
const uint8_t *zerop = memchr (data->d_buf, '\0', data->d_size);
- const uint8_t *crcp = (zerop == NULL
- ? NULL
- : (const uint8_t *) ((uintptr_t) (zerop + 1 + 3)
- & -4));
+ if (zerop == NULL)
+ {
+ error (0, 0, _("no file string in section \"%s\" # %zu in \"%s\""),
+ scnname, elf_ndxscn (scn), fname);
+ continue;
+ }
+ const uint8_t *crcp = (const uint8_t *) ((uintptr_t) (zerop + 1 + 3) & -4);
if (crcp + 4 != (uint8_t *) data->d_buf + data->d_size)
{
error (0, 0, _("invalid format of section \"%s\" # %zu in \"%s\""),
--
2.32.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-01 14:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 14:15 [PATCH] sepdebugcrcfix: Don't crash if .gnu_debuglink doesn't contain a file string 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).