Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Wed, 8 Jan 2025 23:34:21 +0000 (00:34 +0100)
committerMatthias Klose <doko@debian.org>
Wed, 8 Jan 2025 23:34:21 +0000 (00:34 +0100)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index 93adbf117f05fd33191eabbfc1aaf0347e8cde0b..d5e08b298144080f452e894338d61e8741f9b194 100644 (file)
@@ -277,6 +277,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)