_better_file_error
authorMatthias Klose <doko@debian.org>
Sun, 20 Oct 2019 19:28:38 +0000 (20:28 +0100)
committerMatthias Klose <doko@debian.org>
Sun, 20 Oct 2019 19:28:38 +0000 (20:28 +0100)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index 07f89b9a4c152a1c69933cea62a84c5e2c4be3c3..2a8404e214381452525c5e7e894280ba37df566a 100644 (file)
@@ -196,6 +196,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)