Windows: avoid loop on reparse-point cycles

In Windows 10 Fall Creators Update, a OneDrive mount looks to Racket like
a reparse point that refers to itself. Make Racket stop trying to resolve
the path further in that case.

Relevant to #1671
This commit is contained in:
Matthew Flatt 2017-10-24 08:26:26 -06:00
parent ae4e85a6a7
commit 22e8af32f3

View File

@ -349,6 +349,7 @@ static int UNC_stat(rktio_t *rktio, const char *dirname, int *flags, int *isdir,
char *copy; char *copy;
WIN32_FILE_ATTRIBUTE_DATA fad; WIN32_FILE_ATTRIBUTE_DATA fad;
int len, must_be_dir = 0; int len, must_be_dir = 0;
int same_path = 0; /* to give up on cyclic links */
const wchar_t *wp; const wchar_t *wp;
if (resolved_path) if (resolved_path)
@ -420,7 +421,7 @@ static int UNC_stat(rktio_t *rktio, const char *dirname, int *flags, int *isdir,
free(copy); free(copy);
return 0; return 0;
} else { } else {
if (GET_FF_ATTRIBS(fad) & FF_A_LINK) { if ((GET_FF_ATTRIBS(fad) & FF_A_LINK) && !same_path) {
if (islink) { if (islink) {
*islink = 1; *islink = 1;
return 1; return 1;
@ -465,6 +466,8 @@ static int UNC_stat(rktio_t *rktio, const char *dirname, int *flags, int *isdir,
if (resolved_path) if (resolved_path)
*resolved_path = dirname; *resolved_path = dirname;
same_path = !strcmp(dirname, copy);
free(dest); free(dest);
free(copy); free(copy);