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.
This commit is contained in:
Nick Clifton 2021-01-07 12:04:15 +00:00
parent 78e4948694
commit 17d60030ae
2 changed files with 27 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2021-01-07 Nick Clifton <nickc@redhat.com>
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.
2021-01-07 Philipp Tomsich <prt@gnu.org>
* elfxx-riscv.c (riscv_std_z_ext_strtab): Added zihintpause.

View File

@ -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, "\\\\?\\");