diff options
author | Alan Modra <amodra@gmail.com> | 2023-03-09 22:39:30 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-03-09 22:48:06 +1030 |
commit | 093b56776fcf31ecc9342382341c1455fd397b16 (patch) | |
tree | ab60881ddd7291ec1edea59fae54ece9ddd829a8 /binutils | |
parent | 2dc2dfa7d7a53aae58da4a51a77e9ad996cd2937 (diff) | |
download | gdb-093b56776fcf31ecc9342382341c1455fd397b16.zip gdb-093b56776fcf31ecc9342382341c1455fd397b16.tar.gz gdb-093b56776fcf31ecc9342382341c1455fd397b16.tar.bz2 |
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.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/objdump.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c index 97532be..0e8e198 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: |