binutils: support for the SPARC M8 processor
[deliverable/binutils-gdb.git] / binutils / ar.c
index 2765dcc5f799627dcf268564684c8acaeb736072..ef8b5bdb12bede18c47f65e2615b9e0ade8f9a56 100644 (file)
@@ -1,5 +1,5 @@
 /* ar.c - Archive modify and extract.
-   Copyright (C) 1991-2015 Free Software Foundation, Inc.
+   Copyright (C) 1991-2017 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
 #include "progress.h"
 #include "getopt.h"
 #include "aout/ar.h"
-#include "libbfd.h"
 #include "bucomm.h"
 #include "arsup.h"
 #include "filenames.h"
 #include "binemul.h"
+#include "plugin-api.h"
 #include "plugin.h"
 
 #ifdef __GO32___
@@ -738,6 +738,9 @@ main (int argc, char **argv)
 
   arg_index = 0;
 
+  if (argv[arg_index] == NULL)
+    usage (0);
+
   if (mri_mode)
     {
       default_deterministic ();
@@ -776,18 +779,26 @@ main (int argc, char **argv)
       default_deterministic ();
 
       if (postype != pos_default)
-       posname = argv[arg_index++];
+       {
+         posname = argv[arg_index++];
+         if (posname == NULL)
+           fatal (_("missing position arg."));
+       }
 
       if (counted_name_mode)
        {
          if (operation != extract && operation != del)
            fatal (_("`N' is only meaningful with the `x' and `d' options."));
+         if (argv[arg_index] == NULL)
+           fatal (_("`N' missing value."));
          counted_name_counter = atoi (argv[arg_index++]);
          if (counted_name_counter <= 0)
            fatal (_("Value for `N' must be positive."));
        }
 
       inarch_filename = argv[arg_index++];
+      if (inarch_filename == NULL)
+       usage (0);
 
       for (file_count = 0; argv[arg_index + file_count] != NULL; file_count++)
        continue;
@@ -955,7 +966,7 @@ open_inarch (const char *archive_filename, const char *file)
                 bfd_get_filename (arch));
          goto bloser;
        }
-    }  
+    }
 
   last_one = &(arch->archive_next);
   /* Read all the contents right away, regardless.  */
@@ -1003,7 +1014,7 @@ print_contents (bfd *abfd)
       if (nread != tocopy)
        /* xgettext:c-format */
        fatal (_("%s is not a valid archive"),
-              bfd_get_filename (bfd_my_archive (abfd)));
+              bfd_get_filename (abfd->my_archive));
 
       /* fwrite in mingw32 may return int instead of bfd_size_type. Cast the
         return value to bfd_size_type to avoid comparison between signed and
@@ -1081,7 +1092,7 @@ extract_file (bfd *abfd)
        if (nread != tocopy)
          /* xgettext:c-format */
          fatal (_("%s is not a valid archive"),
-                bfd_get_filename (bfd_my_archive (abfd)));
+                bfd_get_filename (abfd->my_archive));
 
        /* See comment above; this saves disk arm motion */
        if (ostream == NULL)
This page took 0.024262 seconds and 4 git commands to generate.