From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] sepdebugcrcfix: Don't crash if .gnu_debuglink doesn't contain a file string.
Date: Thu, 1 Jul 2021 16:15:14 +0200 [thread overview]
Message-ID: <20210701141514.325121-1-mark@klomp.org> (raw)
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
reply other threads:[~2021-07-01 14:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210701141514.325121-1-mark@klomp.org \
--to=mark@klomp.org \
--cc=debugedit@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).