Make the strings utility reject directories.
authorNick Clifton <nickc@redhat.com>
Fri, 23 Jun 2017 09:22:36 +0000 (10:22 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 23 Jun 2017 09:24:39 +0000 (10:24 +0100)
PR binutils/21659
* strings.c (strings_file): Warn about attempts to run strings on
a directory.

binutils/ChangeLog
binutils/strings.c

index 484632a..b4672fa 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-23  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/21659
+       * strings.c (strings_file): Warn about attempts to run strings on
+       a directory.
+
 2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        * readelf.c (decode_x86_feature): Decode
index 13e2619..77d89eb 100644 (file)
@@ -446,6 +446,11 @@ strings_file (char *file)
                   file, strerror (errno));
       return FALSE;
     }
+  else if (S_ISDIR (st.st_mode))
+    {
+      non_fatal (_("Warning: '%s' is a directory"), file);
+      return FALSE;
+    }
 
   /* If we weren't told to scan the whole file,
      try to open it as an object file and only look at