Fix out of bounds memory access when trying to allocate space for a note of size -1.
[deliverable/binutils-gdb.git] / bfd / syms.c
index 5e860f9c102b86cc23794b49a85f5f80cdcd1ee2..090009beebc17393b584c644b2cfcc70ee270eeb 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic symbol-table support for the BFD library.
-   Copyright (C) 1990-2016 Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -231,7 +231,9 @@ CODE_FRAGMENT
 .
 .  {* Used by the linker.  *}
 .#define BSF_KEEP              (1 << 5)
-.#define BSF_KEEP_G            (1 << 6)
+.
+.  {* An ELF common symbol.  *}
+.#define BSF_ELF_COMMON                (1 << 6)
 .
 .  {* A weak global symbol, overridable without warnings by
 .     a regular global symbol of the same name.  *}
@@ -1073,7 +1075,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                  || r->howto->bitpos != 0
                  || r->howto->dst_mask != 0xffffffff)
                {
-                 (*_bfd_error_handler)
+                 _bfd_error_handler
                    (_("Unsupported .stab relocation"));
                  bfd_set_error (bfd_error_invalid_operation);
                  if (reloc_vector != NULL)
@@ -1081,11 +1083,13 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                  return FALSE;
                }
 
-             val = bfd_get_32 (abfd, info->stabs + r->address);
+             val = bfd_get_32 (abfd, info->stabs
+                               + r->address * bfd_octets_per_byte (abfd));
              val &= r->howto->src_mask;
              sym = *r->sym_ptr_ptr;
              val += sym->value + sym->section->vma + r->addend;
-             bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
+             bfd_put_32 (abfd, (bfd_vma) val, info->stabs
+                         + r->address * bfd_octets_per_byte (abfd));
            }
        }
 
This page took 0.026587 seconds and 4 git commands to generate.