From: Nick Clifton <nickc@redhat.com>
To: binutils@sourceware.org
Subject: Commit: Add more tests for corrupt DWARF data
Date: Mon, 19 Dec 2022 11:13:17 +0000 [thread overview]
Message-ID: <87r0wvsl2q.fsf@redhat.com> (raw)
Hi Guys,
I am applying the patch below to add a couple more tests to
binutils/dwarf.c to catch cases of corrupt DWARF information.
Cheers
Nick
binutils/ChangeLog
2022-12-19 Nick Clifton <nickc@redhat.com>
PR 29914
* dwarf.c (fetch_indexed_value): Fail if the section is not big
enough to contain a header size field.
(display_debug_addr): Fail if the computed address size is too big
or too small.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 03b36afcec0..b792902c496 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -739,6 +739,13 @@ fetch_indexed_value (uint64_t idx,
return -1;
}
+ if (section->size < 4)
+ {
+ warn (_("Section %s is too small to contain an value indexed from another section!\n"),
+ section->name);
+ return -1;
+ }
+
uint32_t pointer_size, bias;
if (byte_get (section->start, 4) == 0xffffffff)
@@ -7770,6 +7777,13 @@ display_debug_addr (struct dwarf_section *section,
header = end;
idx = 0;
+ if (address_size < 1 || address_size > sizeof (uint64_t))
+ {
+ warn (_("Corrupt %s section: address size (%x) is wrong"),
+ section->name, address_size);
+ return 0;
+ }
+
while ((size_t) (end - entry) >= address_size)
{
uint64_t base = byte_get (entry, address_size);
reply other threads:[~2022-12-19 11:13 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=87r0wvsl2q.fsf@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@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).