From 48b3bb299f11bd25a8cff31b302e82a5d45ccee5 Mon Sep 17 00:00:00 2001 From: David Kimdon Date: Tue, 30 Jan 2024 11:04:12 +0100 Subject: [PATCH] Specify which filename is causing an error if the filename is a directory. (#45832) Gbp-Pq: Name 006_better_file_error.patch --- bfd/opncls.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bfd/opncls.c b/bfd/opncls.c index a0a5c40fb..d2c3f89dd 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -268,6 +268,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) -- 2.30.2