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] Make the strings utility reject directories.


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

commit 0e158763b0c5671cd40cdd2faee48d6659489ddd
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Jun 23 10:22:36 2017 +0100

    Make the strings utility reject directories.
    
    	PR binutils/21659
    	* strings.c (strings_file): Warn about attempts to run strings on
    	a directory.

Diff:
---
 binutils/ChangeLog | 6 ++++++
 binutils/strings.c | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 484632a..b4672fa 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/strings.c b/binutils/strings.c
index 13e2619..77d89eb 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -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


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