Skip to content

Commit 29e829f

Browse files
committed
Fixed bug #14049 (realpath() w/ZTS returns invalid results for non-existent
paths)
1 parent 1465e10 commit 29e829f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

ext/standard/file.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <sys/stat.h>
4444
#include <fcntl.h>
4545
#ifdef PHP_WIN32
46+
#include <io.h>
4647
#define O_RDONLY _O_RDONLY
4748
#include "win32/param.h"
4849
#include "win32/winutil.h"
@@ -1939,6 +1940,15 @@ PHP_FUNCTION(realpath)
19391940
convert_to_string_ex(path);
19401941

19411942
if (VCWD_REALPATH(Z_STRVAL_PP(path), resolved_path_buff)) {
1943+
#if ZTS
1944+
# if PHP_WIN32
1945+
if (_access(resolved_path_buff, 0))
1946+
RETURN_FALSE;
1947+
# else
1948+
if (access(resolved_path_buff, F_OK))
1949+
RETURN_FALSE;
1950+
# endif
1951+
#endif
19421952
RETURN_STRING(resolved_path_buff, 1);
19431953
} else {
19441954
RETURN_FALSE;

0 commit comments

Comments
 (0)