strings: remove section/file size check
authorAlan Modra <amodra@gmail.com>
Mon, 3 Jul 2017 12:30:32 +0000 (22:00 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 3 Jul 2017 12:33:49 +0000 (22:03 +0930)
commit19871f45ddfa7681f8f7585e73409f4fe5b51258
tree6e22a3de83c92771f71e51f211f9c0dbb66d2421
parent76cfced5addbd827652688a13f9cfa02afce51a5
strings: remove section/file size check

This reverts most of 06803313754, 2005-07-05 Dmitry V. Levin change
adding a check that section size doesn't exceed file size.  As we've
seen recently with mmo tests, decoded section size can easily exceed
file size with formats that encode section data.

I've also changed "strings" to use bfd_malloc_and_get_section, so that
"strings" won't die on a malloc failure.  I think it's better to
continue on looking at other sections after failing to dump a section
with fuzzed size.

The testcases at https://bugzilla.altlinux.org/show_bug.cgi?id=5871
on a 32-bit host now produce
$ strings -d --target=a.out-i386 /tmp/bfdkiller.dat
strings: error: /tmp/bfdkiller.dat(.text) is too large (0xffffffff bytes)
strings: /tmp/bfdkiller.dat: Reading section .text failed: Memory exhausted
strings: /tmp/bfdkiller.dat: Reading section .data failed: File truncated
org.ec
$ strings -d --target=a.out-i386 /tmp/eclipse-state
strings: /tmp/eclipse-state: Reading section .text failed: File truncated
org.eclipse.osgi
System Bundle
[snip]

* strings.c (filename_and_size_t): Delete.
(strings_a_section): Don't check section size against file size.
Use bdf_malloc_and_get_section.  Report an error on failures.
Replace arg param with filename and got_a_section param.
(got_a_section): Move to..
(strings_object_file): ..an auto var here.  Iterate over sections
rather than calling bfd_map_over_sections.  Adjust strings_a_section
call.
binutils/ChangeLog
binutils/strings.c
This page took 0.025827 seconds and 4 git commands to generate.