Specify which filename is causing an error if the filename is a
authorDavid Kimdon <dwhedon@gordian.com>
Mon, 6 Jul 2020 19:10:37 +0000 (20:10 +0100)
committerMatthias Klose <doko@debian.org>
Mon, 6 Jul 2020 19:10:37 +0000 (20:10 +0100)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index c2a1d2fa4df13d649ac6a0c7545766105d800085..f2247d0fe80a20e44fbe35e7dcba21c5400b55e8 100644 (file)
@@ -220,6 +220,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)