--- bfd/peXXigen.c.orig Thu Mar 3 12:41:00 2005 +++ bfd/peXXigen.c Fri Jul 22 10:52:09 2005 @@ -1377,6 +1377,7 @@ return TRUE; addr = section->vma; + dataoff = 0; datasize = section->size; if (datasize == 0) return TRUE; @@ -1387,9 +1388,7 @@ for (section = abfd->sections; section != NULL; section = sect ion->next) { - datasize = section->size; - - if (addr >= section->vma && addr < section->vma + datasize) + if (addr >= section->vma && addr < section->vma + section->size) break; } @@ -1399,14 +1398,21 @@ _("\nThere is an export table, but the section containing it could not be found\n")); return TRUE; } + + dataoff = addr - section->vma; + datasize = extra->DataDirectory[0].Size; + if (datasize > section->size - dataoff) + { + fprintf (file, + _("\nThere is an export table in %s, but it does not fit into that section\n"), + section->name); + return TRUE; + } } fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), section->name, (unsigned long) addr); - dataoff = addr - section->vma; - datasize -= dataoff; - data = (bfd_byte *) bfd_malloc (datasize); if (data == NULL) return FALSE;