Skip to content

Commit cc4c318

Browse files
committed
Check if soap.wsdl_cache_dir confirms to open_basedir
1 parent a80fdc4 commit cc4c318

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

ext/soap/soap.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,44 @@ ZEND_INI_MH(OnUpdateCacheMode)
568568
return SUCCESS;
569569
}
570570

571+
static PHP_INI_MH(OnUpdateCacheDir)
572+
{
573+
/* Only do the safemode/open_basedir check at runtime */
574+
if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) {
575+
char *p;
576+
577+
if (memchr(new_value, '\0', new_value_length) != NULL) {
578+
return FAILURE;
579+
}
580+
581+
/* we do not use zend_memrchr() since path can contain ; itself */
582+
if ((p = strchr(new_value, ';'))) {
583+
char *p2;
584+
p++;
585+
if ((p2 = strchr(p, ';'))) {
586+
p = p2 + 1;
587+
}
588+
} else {
589+
p = new_value;
590+
}
591+
592+
if (PG(safe_mode) && *p && (!php_checkuid(p, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
593+
return FAILURE;
594+
}
595+
596+
if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) {
597+
return FAILURE;
598+
}
599+
}
600+
601+
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
602+
return SUCCESS;
603+
}
604+
571605
PHP_INI_BEGIN()
572606
STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled", "1", PHP_INI_ALL, OnUpdateBool,
573607
cache_enabled, zend_soap_globals, soap_globals)
574-
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateString,
608+
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateCacheDir,
575609
cache_dir, zend_soap_globals, soap_globals)
576610
STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl", "86400", PHP_INI_ALL, OnUpdateLong,
577611
cache_ttl, zend_soap_globals, soap_globals)

0 commit comments

Comments
 (0)