From 4e7ab1478dd040600d854f0699eea7df618e3609 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Mon, 28 Aug 2023 22:22:54 +0100 Subject: [PATCH] Small tyding up of filestat code --- ext/standard/filestat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 1beb0324638..53c7d873a3c 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -721,14 +721,15 @@ PHPAPI void php_stat(zend_string *filename, int type, zval *return_value) } if ((wrapper = php_stream_locate_url_wrapper(ZSTR_VAL(filename), &local, 0)) == &php_plain_files_wrapper - && php_check_open_basedir(local)) { + && php_check_open_basedir(local)) { RETURN_FALSE; } if (wrapper == &php_plain_files_wrapper) { char realpath[MAXPATHLEN]; const char *file_path_to_check; - if (strstr(local, "://") == NULL || expand_filepath(local, realpath) == NULL) { + /* if the wrapper is not found, we need to expand path to match open behavior */ + if (EXPECTED(strstr(local, "://") == NULL || expand_filepath(local, realpath) == NULL)) { file_path_to_check = local; } else { file_path_to_check = realpath;