Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Tue, 18 Jun 2024 12:38:10 +0000 (14:38 +0200)
committerMatthias Klose <doko@debian.org>
Tue, 18 Jun 2024 12:38:10 +0000 (14:38 +0200)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index bc76696dfdbc497c29d44dca3383ce5f5c64f8ee..98cf59991f6048341b639f36752dff56cee8f4ff 100644 (file)
@@ -292,6 +292,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)