_better_file_error
authorMatthias Klose <doko@debian.org>
Wed, 16 May 2018 14:21:19 +0000 (15:21 +0100)
committerMatthias Klose <doko@debian.org>
Wed, 16 May 2018 14:21:19 +0000 (15:21 +0100)
directory. (#45832)

Gbp-Pq: Name 006_better_file_error.patch

bfd/opncls.c

index 458f06ea71bc69665c028011b05645b870150cb1..709689057a423d233897039e15a9b096f3cbe57b 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)