PR25822, Invalid read in process_symbol_table

PR 25822
	* readelf.c (get_num_dynamic_syms): Don't set num_of_syms when
	reading buckets or chains fails.
This commit is contained in:
Alan Modra 2020-04-15 16:38:01 +09:30
parent b71d4fa7c3
commit 001890e1f9
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2020-04-15 Alan Modra <amodra@gmail.com>
PR 25822
* readelf.c (get_num_dynamic_syms): Don't set num_of_syms when
reading buckets or chains fails.
2020-04-15 Alan Modra <amodra@gmail.com>
* readelf.c (process_symbol_table): Zero gnubuckets, gnuchains

View File

@ -9969,11 +9969,13 @@ get_num_dynamic_syms (Filedata * filedata)
nbuckets = byte_get (nb, hash_ent_size);
nchains = byte_get (nc, hash_ent_size);
num_of_syms = nchains;
buckets = get_dynamic_data (filedata, nbuckets, hash_ent_size);
chains = get_dynamic_data (filedata, nchains, hash_ent_size);
if (buckets != NULL && chains != NULL)
num_of_syms = nchains;
no_hash:
if (num_of_syms == 0)
{