Fix realpath not to die on non-existing files (bug #5790)

Thanks to china@thewrittenword.com
This commit is contained in:
Stanislav Malyshev 2000-07-27 13:48:50 +00:00
parent 5ec120366c
commit ba8d49dce7

View file

@ -251,7 +251,9 @@ char *php_realpath(char *path, char resolved_path []) {
}
/* Check if the resolved path is a directory */
if (V_STAT(path_construction, &filestat) != 0) return NULL;
if (V_STAT(path_construction, &filestat) != 0) {
if (errno != ENOENT) return NULL;
} else {
if (S_ISDIR(filestat.st_mode)) {
/* It's a directory, append a / if needed */
if (*(writepos-1) != '/') {
@ -262,6 +264,7 @@ char *php_realpath(char *path, char resolved_path []) {
*writepos = 0;
}
}
}
strcpy(resolved_path, path_construction);
return resolved_path;