Fix out of bounds memory access when trying to allocate space for a note of size -1.
[deliverable/binutils-gdb.git] / bfd / elf32-s390.c
index ddbeb97dfcd5a17dfa90339b4978b4d6fd8bea7f..91853ef2b44a79449e2ccdb113373e92dba16a4c 100644 (file)
@@ -3941,7 +3941,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_PLTRELSZ:
-             dyn.d_un.d_val = htab->elf.srelplt->size + htab->elf.irelplt->size;
+             dyn.d_un.d_val = htab->elf.srelplt->size;
+             if (htab->elf.irelplt)
+               dyn.d_un.d_val += htab->elf.irelplt->size;
              break;
            }
 
@@ -3999,6 +4001,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
 
       symtab_hdr = &elf_symtab_hdr (ibfd);
 
+      if (!is_s390_elf (ibfd))
+       continue;
+
       local_plt = elf_s390_local_plt (ibfd);
       if (local_plt != NULL)
        for (i = 0; i < symtab_hdr->sh_info; i++)
This page took 0.023765 seconds and 4 git commands to generate.