]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Import patch from mainline to improve reporting of corrupt archives.
authorNick Clifton <nickc@redhat.com>
Mon, 4 Sep 2017 15:14:19 +0000 (16:14 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 4 Sep 2017 15:14:19 +0000 (16:14 +0100)
PR 21787
* archive.c (bfd_generic_archive_p): If the bfd does not have the
correct magic bytes at the start, set the error to wrong format
and clear the format selector before returning NULL.

bfd/ChangeLog
bfd/archive.c

index 1bba9454096ef80bd1c8fc4012257c030bfbdabe..7be3d8267a7117a3ca9e3cc60fcff550fd70a219 100644 (file)
        (GET_VALUE_IN_FIELD): New macro.
        (xcoff64_slurp_armap): Use new macros.
 
+       PR 21787
+       * archive.c (bfd_generic_archive_p): If the bfd does not have the
+       correct magic bytes at the start, set the error to wrong format
+       and clear the format selector before returning NULL.
+
 2017-09-04  Alan Modra  <amodra@gmail.com>
 
        PR 22067
index f209babe149f3f5b302da64f593e039c9c79ea8c..885bf489c024a7a24444bb82740987dd20aff184 100644 (file)
@@ -834,7 +834,12 @@ bfd_generic_archive_p (bfd *abfd)
   if (strncmp (armag, ARMAG, SARMAG) != 0
       && strncmp (armag, ARMAGB, SARMAG) != 0
       && ! bfd_is_thin_archive (abfd))
-    return NULL;
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      if (abfd->format == bfd_archive)
+       abfd->format = bfd_unknown;
+      return NULL;
+    }
 
   tdata_hold = bfd_ardata (abfd);