Skip to content

Commit 15383e0

Browse files
committed
- do safemode/open basedir checks 1st, and use only expand not realpath (it is done by the safemode/openbasedir check already)
1 parent ef7229e commit 15383e0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ PHP_FUNCTION(finfo_open)
293293
if (file_len == 0) {
294294
file = NULL;
295295
} else if (file && *file) { /* user specified file, perform open_basedir checks */
296-
if (!VCWD_REALPATH(file, resolved_path)) {
297-
RETURN_FALSE;
298-
}
299-
file = resolved_path;
300296

301297
#if PHP_API_VERSION < 20100412
302298
if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
@@ -305,6 +301,10 @@ PHP_FUNCTION(finfo_open)
305301
#endif
306302
RETURN_FALSE;
307303
}
304+
if (!expand_filepath_with_mode(file, resolved_path, NULL, 0, CWD_EXPAND TSRMLS_CC)) {
305+
RETURN_FALSE;
306+
}
307+
file = resolved_path;
308308
}
309309

310310
finfo = emalloc(sizeof(struct php_fileinfo));

0 commit comments

Comments
 (0)