Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Fri, 18 Feb 2022 04:46:44 +0000 (04:46 +0000)
committerMatthias Klose <doko@debian.org>
Fri, 18 Feb 2022 04:46:44 +0000 (04:46 +0000)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index f0ca9048f68e270f04b1df6a60fd536ac20e5136..00333a4d32ffeb1e9db82365b7f4e408c9f73a25 100644 (file)
@@ -222,6 +222,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)