Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Sat, 14 Jan 2023 17:24:22 +0000 (17:24 +0000)
committerMatthias Klose <doko@debian.org>
Sat, 14 Jan 2023 17:24:22 +0000 (17:24 +0000)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index 9241cd1c537bad7594b843bee2c4fa7680c7734f..472200ea5f2b7f584a170778aa8dd7828522bc1d 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)