diff options
author | Stanislav Malyshev <stas@php.net> | 2000-07-27 13:48:50 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2000-07-27 13:48:50 +0000 |
commit | ba8d49dce7cccb90aa16ebb1abdc66c23f21ea8f (patch) | |
tree | f022a77a9b98c6fdcef8ced074f80119e6106475 | |
parent | 5ec120366cfc3e4400a4c86e9e24aa9a69bc61fc (diff) | |
download | php-git-ba8d49dce7cccb90aa16ebb1abdc66c23f21ea8f.tar.gz |
Fix realpath not to die on non-existing files (bug #5790)
Thanks to china@thewrittenword.com
-rw-r--r-- | main/php_realpath.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/main/php_realpath.c b/main/php_realpath.c index 26a9359e08..339eb2eb8f 100644 --- a/main/php_realpath.c +++ b/main/php_realpath.c @@ -251,15 +251,18 @@ 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 (S_ISDIR(filestat.st_mode)) { - /* It's a directory, append a / if needed */ - if (*(writepos-1) != '/') { - /* Check for overflow */ - if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL; - - *writepos++ = '/'; - *writepos = 0; + 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) != '/') { + /* C heck for overflow */ + if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL; + + *writepos++ = '/'; + *writepos = 0; + } } } |