Skip to content

Commit 3b79941

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #31054 (safe_mode & open_basedir checks only check first
include_path value).
1 parent 56c1b31 commit 3b79941

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ PHP NEWS
3434
PHP). (Marcus)
3535
- Fixed bug #31256 (PHP_EVAL_LIBLINE configure macro does not handle -pthread).
3636
(Jani)
37+
- Fixed bug #31054 (safe_mode & open_basedir checks only check first
38+
include_path value). (Ilia)
3739
- Fixed bug #29683 (headers_list() returns empty array). (Tony)
3840
- Fixed bug #28355 (glob wont error if dir is not readable). (Hartmut)
3941
- Fixed bugs #20382, #28024, #30532, #32086, #32270, #32555, #32588, #33056

main/streams/plain_wrapper.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,24 +1297,24 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
12971297
end++;
12981298
}
12991299
snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
1300-
1301-
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) {
1302-
stream = NULL;
1303-
goto stream_done;
1300+
1301+
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) {
1302+
ptr = end;
1303+
continue;
13041304
}
13051305

13061306
if (PG(safe_mode)) {
13071307
if (VCWD_STAT(trypath, &sb) == 0) {
13081308
/* file exists ... check permission */
13091309
if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) ||
1310-
php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM)) {
1310+
php_checkuid_ex(trypath, mode, CHECKUID_CHECK_MODE_PARAM, CHECKUID_NO_ERRORS)) {
13111311
/* UID ok, or trypath is in safe_mode_include_dir */
13121312
stream = php_stream_fopen_rel(trypath, mode, opened_path, options);
1313-
} else {
1314-
stream = NULL;
1313+
goto stream_done;
13151314
}
1316-
goto stream_done;
13171315
}
1316+
ptr = end;
1317+
continue;
13181318
}
13191319
stream = php_stream_fopen_rel(trypath, mode, opened_path, options);
13201320
if (stream) {

0 commit comments

Comments
 (0)