Skip to content

Commit cd145e7

Browse files
committed
Merge branch 'js/maint-add-path-stat-pwd' into maint
* js/maint-add-path-stat-pwd: get_pwd_cwd(): Do not trust st_dev/st_ino blindly
2 parents 8516c1c + 7d092ad commit cd145e7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

abspath.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ static const char *get_pwd_cwd(void)
102102
pwd = getenv("PWD");
103103
if (pwd && strcmp(pwd, cwd)) {
104104
stat(cwd, &cwd_stat);
105-
if (!stat(pwd, &pwd_stat) &&
105+
if ((cwd_stat.st_dev || cwd_stat.st_ino) &&
106+
!stat(pwd, &pwd_stat) &&
106107
pwd_stat.st_dev == cwd_stat.st_dev &&
107108
pwd_stat.st_ino == cwd_stat.st_ino) {
108109
strlcpy(cwd, pwd, PATH_MAX);

0 commit comments

Comments
 (0)