This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] PR 21418, ar -N lacks arg check


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=42354845ae5e00ec1c3519e1f2166b79a9533401

commit 42354845ae5e00ec1c3519e1f2166b79a9533401
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Apr 23 17:39:48 2017 +0930

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

Diff:
---
 binutils/ChangeLog | 5 +++++
 binutils/ar.c      | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

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."));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]