Avoid coff OOM
authorAlan Modra <amodra@gmail.com>
Tue, 11 Nov 2014 11:06:37 +0000 (21:36 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 11 Nov 2014 11:43:57 +0000 (22:13 +1030)
commitfcfa62408aec326a54765a6fd8895349fb41eb7c
tree2f47949b913aad30e85ace57be1e897fcd4a9b6b
parent4de1599bcf044a5396ec588f90b8f475be657d4f
Avoid coff OOM

bfd_zalloc/bfd_zmalloc to fix uninitialized memory reads is too big a
hammer, when the size allocated depends on user input.  A typical
bfd_alloc, bfd_seek, bfd_bread sequence will give an error or warning
at the point the file read fails when some enormous item as described
by headers is not actually present in the file.  Nice operating system
allow memory overcommit.  But not if you write to the memory.  So
bfd_zalloc can cause an OOM, thrashing, or system hangs.

The patch also fixes a recently introduced endless loop on bad input.

PR binutils/17512
* coffcode.h (coff_slurp_line_table): Don't bfd_zalloc, just
memset the particular bits we need.  Update src after hitting loop
"continue".  Don't count lineno omitted due to invalid symbols in
nbr_func, and update lineno_count.  Init entire terminating
lineno.  Don't both allocating terminator in n_lineno_cache.
Redirect sym->lineno pointer to where n_lineno_cache will be
copied, and free n_lineno_cache.
* pe-mips.c (NUM_HOWTOS): Typo fix.
bfd/ChangeLog
bfd/coffcode.h
bfd/pe-mips.c
This page took 0.024329 seconds and 4 git commands to generate.