From: Jaydeep Chauhan Date: Mon, 18 May 2020 10:36:26 +0000 (+0100) Subject: Fix the BFD library to handle Windows pathnames with more than 260 characters and... X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=ca859a893931d6fad8b35cf2c20afd43422a59fe;p=deliverable%2Fbinutils-gdb.git 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 06a9f125af..b3cefd9488 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-05-18 Jaydeep Chauhan + + PR 25713 + * bfdio.c (_bfd_real_fopen): Convert UNIX style sirectory + separators into DOS style when creating a WIN32 fullpath. + 2020-05-14 Nelson Chu * elfnn-riscv.c (elfNN_riscv_mkobject): New function. We need this diff --git a/bfd/bfdio.c b/bfd/bfdio.c index 29834d9c6b..bba8d896d3 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;