Sanity check SHT_MIPS_OPTIONS size
authorAlan Modra <amodra@gmail.com>
Thu, 10 Nov 2022 23:22:43 +0000 (09:52 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 11 Nov 2022 07:35:36 +0000 (18:05 +1030)
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Use
bfd_malloc_and_get_section to read contents of .MIPS.options.

bfd/elfxx-mips.c

index e0e23926f0397349b4eeac45fcdb57a8ecacf069..932167c15c66e587dacfabe41df3a341f8fb32a8 100644 (file)
@@ -7523,11 +7523,7 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd,
     {
       bfd_byte *contents, *l, *lend;
 
-      contents = bfd_malloc (hdr->sh_size);
-      if (contents == NULL)
-       return false;
-      if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
-                                     0, hdr->sh_size))
+      if (!bfd_malloc_and_get_section (abfd, hdr->bfd_section, &contents))
        {
          free (contents);
          return false;