Fix invocation of stat() on a NULL pointer.
authorNick Clifton <nickc@redhat.com>
Wed, 26 Apr 2017 14:42:03 +0000 (15:42 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 26 Apr 2017 14:42:03 +0000 (15:42 +0100)
PR binutils/21407
* bucomm.c (get_file_size): Return -1 if file_name is NULL.
* ar.c (main): Fail with usage() invocation if no file names are
provided.

binutils/ChangeLog
binutils/ar.c
binutils/bucomm.c

index e1736b9926975673c209a80f4036c6eee0ce5b0d..b37d5b3dcbfb80425163b199fdf1eedd4c3935ad 100644 (file)
@@ -1,3 +1,10 @@
+2017-04-26  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/21407
+       * bucomm.c (get_file_size): Return -1 if file_name is NULL.
+       * ar.c (main): Fail with usage() invocation if no file names are
+       provided.
+
 2017-04-26  Nick Clifton  <nickc@redhat.com>
 
        * readelf.c (process_section_headers): Warn about overlarge
index 32ac4040c6b5f8ac933dc2bc33722e3a08b08e06..ef8b5bdb12bede18c47f65e2615b9e0ade8f9a56 100644 (file)
@@ -738,6 +738,9 @@ main (int argc, char **argv)
 
   arg_index = 0;
 
+  if (argv[arg_index] == NULL)
+    usage (0);
+
   if (mri_mode)
     {
       default_deterministic ();
index e682717b8d525923633946a4ea654e38e31e5822..fd6f35604d88d18a7bd5db5f37e4ab5f885c4cfb 100644 (file)
@@ -587,6 +587,9 @@ get_file_size (const char * file_name)
 {
   struct stat statbuf;
 
+  if (file_name == NULL)
+    return (off_t) -1;
+
   if (stat (file_name, &statbuf) < 0)
     {
       if (errno == ENOENT)
This page took 0.039966 seconds and 4 git commands to generate.