* [binutils-gdb] objdump: report no section contents
@ 2023-03-09 12:18 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-03-09 12:18 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=093b56776fcf31ecc9342382341c1455fd397b16
commit 093b56776fcf31ecc9342382341c1455fd397b16
Author: Alan Modra <amodra@gmail.com>
Date: Thu Mar 9 22:39:30 2023 +1030
objdump: report no section contents
objdump's read_section is never used for bss-style sections, so to
plug a hole that fuzzers have found, exclude sections without
SEC_HAS_CONTENTS.
* objdump.c (read_section): Report and return an error on
a no contents section.
Diff:
---
binutils/objdump.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 97532bed97c..0e8e1980b80 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4477,16 +4477,16 @@ read_section (bfd *abfd, const char *sect_name, bfd_byte **contents)
return NULL;
}
- if (!bfd_malloc_and_get_section (abfd, sec, contents))
- {
- non_fatal (_("reading %s section of %s failed: %s"),
- sect_name, bfd_get_filename (abfd),
- bfd_errmsg (bfd_get_error ()));
- exit_status = 1;
- return NULL;
- }
-
- return sec;
+ if ((bfd_section_flags (sec) & SEC_HAS_CONTENTS) == 0)
+ bfd_set_error (bfd_error_no_contents);
+ else if (bfd_malloc_and_get_section (abfd, sec, contents))
+ return sec;
+
+ non_fatal (_("reading %s section of %s failed: %s"),
+ sect_name, bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ exit_status = 1;
+ return NULL;
}
/* Stabs entries use a 12 byte format:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-09 12:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 12:18 [binutils-gdb] objdump: report no section contents Alan Modra
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).