aboutsummaryrefslogtreecommitdiff
path: root/bfd/pe-mips.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-11-11 21:36:37 +1030
committerAlan Modra <amodra@gmail.com>2014-11-11 22:13:57 +1030
commitfcfa62408aec326a54765a6fd8895349fb41eb7c (patch)
tree2f47949b913aad30e85ace57be1e897fcd4a9b6b /bfd/pe-mips.c
parent4de1599bcf044a5396ec588f90b8f475be657d4f (diff)
downloadgdb-fcfa62408aec326a54765a6fd8895349fb41eb7c.zip
gdb-fcfa62408aec326a54765a6fd8895349fb41eb7c.tar.gz
gdb-fcfa62408aec326a54765a6fd8895349fb41eb7c.tar.bz2
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.
Diffstat (limited to 'bfd/pe-mips.c')
-rw-r--r--bfd/pe-mips.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bfd/pe-mips.c b/bfd/pe-mips.c
index 940c069..57ec51f 100644
--- a/bfd/pe-mips.c
+++ b/bfd/pe-mips.c
@@ -339,7 +339,7 @@ static reloc_howto_type howto_table[] =
FALSE), /* Pcrel_offset. */
};
-#define NUM_HOWTOS ((sizeof (howto_table) / sizeof (howto_table[0]))
+#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
/* Turn a howto into a reloc nunmber. */