Skip to content

Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured #19487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,10 +2037,8 @@ PHP_FUNCTION(ini_set)
#define _CHECK_PATH(var, var_len, ini) php_ini_check_path(var, var_len, ini, sizeof(ini))
/* open basedir check */
if (PG(open_basedir)) {
if (_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "error_log") ||
_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.class.path") ||
if (_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.class.path") ||
_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.home") ||
_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "mail.log") ||
_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.library.path") ||
_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "vpopmail.directory")) {
if (php_check_open_basedir(ZSTR_VAL(new_value_str))) {
Expand Down
12 changes: 7 additions & 5 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,26 +625,28 @@ static PHP_INI_MH(OnUpdateErrorLog)
{
/* Only do the safemode/open_basedir check at runtime */
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) &&
new_value && zend_string_equals_literal(new_value, "syslog")) {
new_value && !zend_string_equals_literal(new_value, "syslog") && ZSTR_LEN(new_value) > 0) {
if (PG(open_basedir) && php_check_open_basedir(ZSTR_VAL(new_value))) {
return FAILURE;
}
}
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
char **p = (char **) ZEND_INI_GET_ADDR();
*p = new_value && ZSTR_LEN(new_value) > 0 ? ZSTR_VAL(new_value) : NULL;
return SUCCESS;
}
/* }}} */

/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateMailLog)
{
/* Only do the safemode/open_basedir check at runtime */
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value) {
/* Only do the open_basedir check at runtime */
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value && ZSTR_LEN(new_value) > 0) {
if (PG(open_basedir) && php_check_open_basedir(ZSTR_VAL(new_value))) {
return FAILURE;
}
}
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
char **p = (char **) ZEND_INI_GET_ADDR();
*p = new_value && ZSTR_LEN(new_value) > 0 ? ZSTR_VAL(new_value) : NULL;
return SUCCESS;
}
/* }}} */
Expand Down
13 changes: 13 additions & 0 deletions tests/security/error_log_special_values.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Setting error_log to special values with open_basedir enabled
--INI--
open_basedir=foo
error_log=
--FILE--
<?php
var_dump(ini_set("error_log", "syslog"));
var_dump(ini_set("error_log", ""));
?>
--EXPECT--
string(0) ""
string(6) "syslog"
Loading