aboutsummaryrefslogtreecommitdiff
path: root/binutils/coffdump.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-01-06 16:06:45 +0000
committerNick Clifton <nickc@redhat.com>2015-01-06 16:06:45 +0000
commit85880250e591a51624d24db653aaace0c5ce5943 (patch)
tree0319d173921cd8ec36f007e0270dc883a30e8336 /binutils/coffdump.c
parentfce10a8494efa8faec67b718f25e06d3d71694b3 (diff)
downloadgdb-85880250e591a51624d24db653aaace0c5ce5943.zip
gdb-85880250e591a51624d24db653aaace0c5ce5943.tar.gz
gdb-85880250e591a51624d24db653aaace0c5ce5943.tar.bz2
Fixes for memory access violations in the coffdump program.
PR binutils/17512 * coffdump.c (dump_coff_section): Check for a symbol being available before printing its name. (main): Check the return value from coff_grok. * coffgrok.c: Reformat and tidy. Add range checks to most functions. (coff_grok): Return NULL if the input bfd is not in a COFF format. * coffgrok.h: Reformat and tidy. (struct coff_section): Change the nrelocs field to unsigned. * srconv.c (main): Check the return value from coff_grok. * coff-i860.c (CALC_ADDEND): Always set an addend value. * tekhex.c (getvalue): Add an end pointer parameter. Use it to avoid reading off the end of the buffer. (getsym): Likewise. (first_phase): Likewise. (pass_over): Pass an end pointer to the invoked function.
Diffstat (limited to 'binutils/coffdump.c')
-rw-r--r--binutils/coffdump.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/binutils/coffdump.c b/binutils/coffdump.c
index b952b62..9883e22 100644
--- a/binutils/coffdump.c
+++ b/binutils/coffdump.c
@@ -417,21 +417,23 @@ dump_coff_sfile (struct coff_sfile *p)
static void
dump_coff_section (struct coff_section *ptr)
{
- int i;
+ unsigned int i;
tab (1);
- printf (_("section %s %d %d address %x size %x number %d nrelocs %d"),
+ printf (_("section %s %d %d address %x size %x number %d nrelocs %u"),
ptr->name, ptr->code, ptr->data, ptr->address,ptr->size,
ptr->number, ptr->nrelocs);
nl ();
for (i = 0; i < ptr->nrelocs; i++)
{
+ struct coff_reloc * r = ptr->relocs + i;
tab (0);
printf ("(%x %s %x)",
- ptr->relocs[i].offset,
- ptr->relocs[i].symbol->name,
- ptr->relocs[i].addend);
+ r->offset,
+ /* PR 17512: file: 0a38fb7c. */
+ r->symbol == NULL ? _("<no sym>") : r->symbol->name,
+ r->addend);
nl ();
}
@@ -549,9 +551,11 @@ main (int ac, char **av)
}
tree = coff_grok (abfd);
-
- coff_dump (tree);
- printf ("\n");
+ if (tree)
+ {
+ coff_dump (tree);
+ printf ("\n");
+ }
return 0;
}