readelf: memory leaks in process_dynamic_section
authorAlan Modra <amodra@gmail.com>
Fri, 24 Apr 2020 00:21:38 +0000 (09:51 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 24 Apr 2020 01:22:26 +0000 (10:52 +0930)
commit2482f30615136c7ed2082561f8e9dba48ee3ee25
treedf3f56c4b291b8997174c1eceb7c8e0526b6babc
parent5e5bbc7e7917e23068a1b0bba381d125b5c9c7c1
readelf: memory leaks in process_dynamic_section

This fixes some code that assumed only one PT_LOAD would contain
DT_SYMTAB.  Which is normally the case, but fuzzers thoroughly mess
with object files.

* readelf.c (get_num_dynamic_syms): Check for nbuckets and nchains
non-zero.
(process_dynamic_section): Call get_num_dynamic_syms once rather
than in segment loop.  Break out of segment loop on a successful
load of dynamic symbols.  Formatting.
(process_object): Return error status from process_dynamic_section.
binutils/ChangeLog
binutils/readelf.c