/* Support for the generic parts of PE/PEI, for BFD.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
Written by Cygnus Solutions.
This file is part of BFD, the Binary File Descriptor library.
case IMPORT_CONST:
/* XXX code yet to be written. */
+ /* xgettext:c-format */
_bfd_error_handler (_("%B: Unhandled import type; %x"),
abfd, import_type);
return FALSE;
default:
+ /* xgettext:c-format */
_bfd_error_handler (_("%B: Unrecognised import type; %x"),
abfd, import_type);
return FALSE;
break;
default:
+ /* xgettext:c-format */
_bfd_error_handler (_("%B: Unrecognised import name type; %x"),
abfd, import_name_type);
return FALSE;
if (import_name_type == IMPORT_ORDINAL)
{
if (ordinal == 0)
- /* XXX - treat as IMPORT_NAME ??? */
- abort ();
+ /* See PR 20907 for a reproducer. */
+ goto error_return;
#ifdef COFF_WITH_pex64
((unsigned int *) id4->contents)[0] = ordinal;
/* We no longer support PowerPC. */
default:
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: Unrecognised machine type (0x%x)"
" in Import Library Format archive"),
abfd, machine);
if (magic == 0)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: Recognised but unhandled machine type (0x%x)"
" in Import Library Format archive"),
abfd, machine);
}
symbol_name = (char *) ptr;
- source_dll = symbol_name + strlen (symbol_name) + 1;
+ /* See PR 20905 for an example of where the strnlen is necessary. */
+ source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1;
/* Verify that the strings are null terminated. */
if (ptr[size - 1] != 0
}
static void
-pe_bfd_read_buildid(bfd *abfd)
+pe_bfd_read_buildid (bfd *abfd)
{
pe_data_type *pe = pe_data (abfd);
struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
addr += extra->ImageBase;
- /* Search for the section containing the DebugDirectory */
+ /* Search for the section containing the DebugDirectory. */
for (section = abfd->sections; section != NULL; section = section->next)
{
if ((addr >= section->vma) && (addr < (section->vma + section->size)))
}
if (section == NULL)
- {
- return;
- }
- else if (!(section->flags & SEC_HAS_CONTENTS))
- {
- return;
- }
+ return;
+
+ if (!(section->flags & SEC_HAS_CONTENTS))
+ return;
dataoff = addr - section->vma;
+ /* PR 20605: Make sure that the data is really there. */
+ if (dataoff + size > section->size)
+ {
+ _bfd_error_handler (_("%B: Error: Debug Data ends beyond end of debug directory."),
+ abfd);
+ return;
+ }
+
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
(file_ptr) idd.PointerToRawData,
idd.SizeOfData, cvinfo))
{
- struct bfd_build_id* build_id = bfd_alloc(abfd,
- sizeof(struct bfd_build_id) + cvinfo->SignatureLength);
+ struct bfd_build_id* build_id = bfd_alloc (abfd,
+ sizeof (struct bfd_build_id) + cvinfo->SignatureLength);
if (build_id)
{
build_id->size = cvinfo->SignatureLength;