+2020-03-20 Nick Clifton <nickc@redhat.com>
+
+ * readelf.c (get_compression_header): Add ATTRIBUTE_WARN_UNUSED_RESULT.
+ (process_section_headers): Check the return value from
+ get_compression_header.
+ (dump_section_as_strings): Likewise.
+ (dump_section_as_bytes): Likewise.
+ (load_specific_debug_section): Likewise.
+
2020-03-20 H.J. Lu <hongjiu.lu@intel.com>
* ar.c (main): Update bfd_plugin_set_program_name call.
return buff;
}
-static unsigned int
+static unsigned int ATTRIBUTE_WARN_UNUSED_RESULT
get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf, bfd_size_type size)
{
if (is_32bit_elf)
{
Elf_Internal_Chdr chdr;
- (void) get_compression_header (&chdr, buf, sizeof (buf));
-
- if (chdr.ch_type == ELFCOMPRESS_ZLIB)
- printf (" ZLIB, ");
+ if (get_compression_header (&chdr, buf, sizeof (buf)) == 0)
+ printf (_(" [<corrupt>]\n"));
else
- printf (_(" [<unknown>: 0x%x], "),
- chdr.ch_type);
- print_vma (chdr.ch_size, LONG_HEX);
- printf (", %lu\n", (unsigned long) chdr.ch_addralign);
+ {
+ if (chdr.ch_type == ELFCOMPRESS_ZLIB)
+ printf (" ZLIB, ");
+ else
+ printf (_(" [<unknown>: 0x%x], "),
+ chdr.ch_type);
+ print_vma (chdr.ch_size, LONG_HEX);
+ printf (", %lu\n", (unsigned long) chdr.ch_addralign);
+ }
}
}
}
unsigned int compression_header_size
= get_compression_header (& chdr, (unsigned char *) start,
num_bytes);
+ if (compression_header_size == 0)
+ /* An error message will have already been generated
+ by get_compression_header. */
+ goto error_out;
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
{
unsigned int compression_header_size
= get_compression_header (& chdr, start, section_size);
+ if (compression_header_size == 0)
+ /* An error message will have already been generated
+ by get_compression_header. */
+ goto error_out;
+
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
{
warn (_("section '%s' has unsupported compress type: %d\n"),
}
compression_header_size = get_compression_header (&chdr, start, size);
+ if (compression_header_size == 0)
+ /* An error message will have already been generated
+ by get_compression_header. */
+ return FALSE;
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
{