Skip to content

Commit 030d815

Browse files
dschoderrickstolee
authored andcommitted
Merge pull request #2673 from dscho/also-handle-fscache-addon-for-#2637
Fix `lstat()`'s `st_size` computation for symbolic links when FSCache is in effect
2 parents 71d253f + f1de7e3 commit 030d815

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compat/win32/fscache.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,18 @@ int fscache_lstat(const char *filename, struct stat *st)
597597
if (!fse)
598598
return -1;
599599

600+
/*
601+
* Special case symbolic links: FindFirstFile()/FindNextFile() did not
602+
* provide us with the length of the target path.
603+
*/
604+
if (fse->u.s.st_size == MAX_LONG_PATH && S_ISLNK(fse->st_mode)) {
605+
char buf[MAX_LONG_PATH];
606+
int len = readlink(filename, buf, sizeof(buf) - 1);
607+
608+
if (len > 0)
609+
fse->u.s.st_size = len;
610+
}
611+
600612
/* copy stat data */
601613
st->st_ino = 0;
602614
st->st_gid = 0;

0 commit comments

Comments
 (0)