From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR29171, invalid read causing SIGSEGV
Date: Tue, 24 May 2022 13:49:13 +0930 [thread overview]
Message-ID: <YoxcwVds6oDPp3Sn@squeak.grove.modra.org> (raw)
The fix here is to pass "section" down to read_and_display_attr_value.
The test in read_and_display_attr_value is a little bit of hardening.
PR 29171
* dwarf.c (display_debug_macro, display_debug_names): Pass section
to read_and_display_attr_value2.
(read_and_display_attr_value): Don't attempt to check for .dwo
section name when section is NULL.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index d820c21527f..a0dfd4df481 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2717,7 +2717,7 @@ read_and_display_attr_value (unsigned long attribute,
case DW_FORM_strx4:
if (!do_loc)
{
- const char *suffix = strrchr (section->name, '.');
+ const char *suffix = section ? strrchr (section->name, '.') : NULL;
bool dwo = suffix && strcmp (suffix, ".dwo") == 0;
if (do_wide)
@@ -6273,8 +6273,9 @@ display_debug_macro (struct dwarf_section *section,
SAFE_BYTE_GET_AND_INC (val, desc, 1, end);
curr
= read_and_display_attr_value (0, val, 0,
- start, curr, end, 0, 0, offset_size,
- version, NULL, 0, NULL,
+ start, curr, end, 0, 0,
+ offset_size, version,
+ NULL, 0, section,
NULL, ' ', -1);
if (n != nargs - 1)
printf (",");
@@ -10310,7 +10311,7 @@ display_debug_names (struct dwarf_section *section, void *file)
unit_start, entryptr, unit_end,
0, 0, offset_size,
dwarf_version, NULL,
- (tagno < 0), NULL,
+ (tagno < 0), section,
NULL, '=', -1);
}
++tagno;
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-05-24 4:19 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=YoxcwVds6oDPp3Sn@squeak.grove.modra.org \
--to=amodra@gmail.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).