Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Wed, 22 Jan 2020 06:49:18 +0000 (06:49 +0000)
committerPeter Michael Green <plugwash@raspbian.org>
Wed, 22 Jan 2020 06:49:18 +0000 (06:49 +0000)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index a03ad51c8fae9a3a19ec610234f969621877b885..c89226c70ca579643ea7dd06c7ce89893a72cbdc 100644 (file)
@@ -196,6 +196,13 @@ bfd_fopen (const char *filename, const char *target, const char *mode, int fd)
 {
   bfd *nbfd;
   const bfd_target *target_vec;
+  struct stat s;
+
+  if (stat (filename, &s) == 0)
+    if (S_ISDIR(s.st_mode)) {
+      bfd_set_error (bfd_error_file_not_recognized);
+      return NULL;
+    }
 
   nbfd = _bfd_new_bfd ();
   if (nbfd == NULL)