[PATCH] sepdebugcrcfix: Don't crash if .gnu_debuglink doesn't contain a file string.
Mark Wielaard
mark@klomp.org
Thu Jul 1 14:15:14 GMT 2021
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
More information about the Debugedit
mailing list