public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR 21418, ar -N lacks arg check
@ 2017-04-23 11:52 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2017-04-23 11:52 UTC (permalink / raw)
  To: binutils

	PR 21418
	* ar.c (main): Check -a, -b, -i and -N args are given.

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 13a665c..eb540fa 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,10 @@
 2017-04-23  Alan Modra  <amodra@gmail.com>
 
+	PR 21418
+	* ar.c (main): Check -a, -b, -i and -N args are given.
+
+2017-04-23  Alan Modra  <amodra@gmail.com>
+
 	PR 21417
 	* ar.c (main): Check that an archive file is given after options.
 
diff --git a/binutils/ar.c b/binutils/ar.c
index 8e4d81c..32ac404 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -776,12 +776,18 @@ 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."));

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-23 11:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 11:52 PR 21418, ar -N lacks arg check Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).