]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix potential segfault
authorAlan Modra <amodra@gmail.com>
Sat, 23 May 2020 07:21:30 +0000 (16:51 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 23 May 2020 07:26:38 +0000 (16:56 +0930)
Code in vms-lib.c leaves arch_header NULL.

* bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.

bfd/ChangeLog
bfd/bfdio.c

index 90274890ea9776ade95fbc0cc0f479575bc264ed..2da474e02c9790cf9d33131f01a0f1624bf597df 100644 (file)
@@ -1,3 +1,7 @@
+2020-05-23  Alan Modra  <amodra@gmail.com>
+
+       * bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
+
 2020-05-22  Alan Modra  <amodra@gmail.com>
 
        PR 25882
index 5ef3ec493ea5f11665a929d51c23424bd2e31b83..5f144bc7f3fee833ff97924ec8f2e3eec37364b9 100644 (file)
@@ -495,8 +495,9 @@ bfd_get_file_size (bfd *abfd)
       struct areltdata *adata = (struct areltdata *) abfd->arelt_data;
       archive_size = adata->parsed_size;
       /* If the archive is compressed we can't compare against file size.  */
-      if (memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag,
-                 "Z\012", 2) == 0)
+      if (adata->arch_header != NULL
+         && memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag,
+                    "Z\012", 2) == 0)
        return archive_size;
       abfd = abfd->my_archive;
     }