aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-01-07 12:04:15 +0000
committerNick Clifton <nickc@redhat.com>2021-01-07 12:05:43 +0000
commit17d60030ae57fb53f5977fa6928d7d5006f42881 (patch)
tree03056339f414ae52e055847569a1705458e56241 /bfd/bfdio.c
parent78e49486944c515dfed6a437edff4c2c15dd1d4e (diff)
downloadgdb-17d60030ae57fb53f5977fa6928d7d5006f42881.zip
gdb-17d60030ae57fb53f5977fa6928d7d5006f42881.tar.gz
gdb-17d60030ae57fb53f5977fa6928d7d5006f42881.tar.bz2
Fix another path length problem opening files on Win32 systems.
PR 25713 * bfdio.c (_bfd_real_fopen): For Win32 convert relative paths to absolute paths and check to see if they are longer than MAX_PATH.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 1b3e13e..463b387 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -116,14 +116,33 @@ _bfd_real_fopen (const char *filename, const char *modes)
}
#elif defined (_WIN32)
- size_t filelen = strlen (filename) + 1;
+ size_t filelen;
+
+ /* PR 25713: Handle extra long path names.
+ For relative paths, convert them to absolute, in case that version is too long. */
+ if (! IS_ABSOLUTE_PATH (filename) && (strstr (filename, ".o") != NULL))
+ {
+ char cwd[1024];
+
+ getcwd (cwd, sizeof (cwd));
+ filelen = strlen (cwd) + 1;
+ strncat (cwd, "\\", sizeof (cwd) - filelen);
+ ++ filelen;
+ strncat (cwd, filename, sizeof (cwd) - filelen);
+
+ filename = cwd;
+ }
+
+ filelen = strlen (filename) + 1;
if (filelen > MAX_PATH - 1)
{
FILE * file;
- char * fullpath = (char *) malloc (filelen + 8);
+ char * fullpath;
int i;
+ fullpath = (char *) malloc (filelen + 8);
+
/* Add a Microsoft recommended prefix that
will allow the extra-long path to work. */
strcpy (fullpath, "\\\\?\\");