aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorJaydeep Chauhan <jaydeepchauhan1494@gmail.com>2020-05-18 11:36:26 +0100
committerNick Clifton <nickc@redhat.com>2020-05-18 11:36:26 +0100
commitca859a893931d6fad8b35cf2c20afd43422a59fe (patch)
tree31d6e9d7b167abcb916ef24cc8615ca014d4c87a /bfd/bfdio.c
parent5e365e474b7561318ddb1a107f05cf0c002e8284 (diff)
downloadgdb-ca859a893931d6fad8b35cf2c20afd43422a59fe.zip
gdb-ca859a893931d6fad8b35cf2c20afd43422a59fe.tar.gz
gdb-ca859a893931d6fad8b35cf2c20afd43422a59fe.tar.bz2
Fix the BFD library to handle Windows pathnames with more than 260 characters and UNIX style directory separators.
PR 25713 * bfdio.c (_bfd_real_fopen): Convert UNIX style sirectory separators into DOS style when creating a WIN32 fullpath.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 29834d9..bba8d89 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -120,13 +120,22 @@ _bfd_real_fopen (const char *filename, const char *modes)
if (filelen > MAX_PATH - 1)
{
- FILE *file;
- char* fullpath = (char *) malloc (filelen + 8);
+ FILE * file;
+ char * fullpath = (char *) malloc (filelen + 8);
+ int i;
/* Add a Microsoft recommended prefix that
will allow the extra-long path to work. */
strcpy (fullpath, "\\\\?\\");
strcat (fullpath, filename);
+
+ /* Convert any UNIX style path separators into the DOS form. */
+ for (i = 0, fullpath[i]; i++)
+ {
+ if (IS_UNIX_DIR_SEPARATOR (fullpath[i]))
+ fullpath[i] = '\\';
+ }
+
file = close_on_exec (fopen (fullpath, modes));
free (fullpath);
return file;