From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Fix an attempt to allocate an excessive amount of memory when parsing a corrupt DWARF file.
Date: Tue, 11 Apr 2023 15:15:08 +0000 (GMT) [thread overview]
Message-ID: <20230411151508.AED8C385840F@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9f1c612b7c1bb2d3035ca9416e5f09d844620e89
commit 9f1c612b7c1bb2d3035ca9416e5f09d844620e89
Author: Nick Clifton <nickc@redhat.com>
Date: Tue Apr 11 16:14:23 2023 +0100
Fix an attempt to allocate an excessive amount of memory when parsing a corrupt DWARF file.
PR 30313
* dwarf.c (display_debug_lines_decoded): Check for an overlarge number of files or directories.
Diff:
---
binutils/ChangeLog | 4 ++++
binutils/dwarf.c | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 285b90c2a68..59ab08a26e6 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,9 @@
2023-04-11 Nick Clifton <nickc@redhat.com>
+ PR 30313
+ * dwarf.c (display_debug_lines_decoded): Check for an overlarge
+ number of files or directories.
+
PR 30312
* dwarf.c (prealloc_cu_tu_list): Always allocate at least one
entry.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index ab0a3caf632..f6ff238d3cb 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4997,6 +4997,12 @@ display_debug_lines_decoded (struct dwarf_section * section,
if (n_directories == 0)
directory_table = NULL;
+ else if (n_directories > section->size)
+ {
+ warn (_("number of directories (0x%x) exceeds size of section %s\n"),
+ n_directories, section->name);
+ return 0;
+ }
else
directory_table = (char **)
xcalloc (n_directories, sizeof (unsigned char *));
@@ -5055,6 +5061,7 @@ display_debug_lines_decoded (struct dwarf_section * section,
if (do_checks && format_count > 5)
warn (_("Unexpectedly large number of columns in the file name table (%u)\n"),
format_count);
+
format_start = data;
for (formati = 0; formati < format_count; formati++)
{
@@ -5071,6 +5078,12 @@ display_debug_lines_decoded (struct dwarf_section * section,
if (n_files == 0)
file_table = NULL;
+ else if (n_files > section->size)
+ {
+ warn (_("number of files (0x%x) exceeds size of section %s\n"),
+ n_files, section->name);
+ return 0;
+ }
else
file_table = (File_Entry *) xcalloc (n_files,
sizeof (File_Entry));
reply other threads:[~2023-04-11 15: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=20230411151508.AED8C385840F@sourceware.org \
--to=nickc@sourceware.org \
--cc=bfd-cvs@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).