Skip to content

Commit c5b33c7

Browse files
dstogovsmalyshev
authored andcommitted
Check if soap.wsdl_cache_dir confirms to open_basedir
1 parent fdf1231 commit c5b33c7

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
@@ -479,10 +479,44 @@ ZEND_INI_MH(OnUpdateCacheMode)
479479
return SUCCESS;
480480
}
481481

482+
static PHP_INI_MH(OnUpdateCacheDir)
483+
{
484+
/* Only do the safemode/open_basedir check at runtime */
485+
if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) {
486+
char *p;
487+
488+
if (memchr(new_value, '\0', new_value_length) != NULL) {
489+
return FAILURE;
490+
}
491+
492+
/* we do not use zend_memrchr() since path can contain ; itself */
493+
if ((p = strchr(new_value, ';'))) {
494+
char *p2;
495+
p++;
496+
if ((p2 = strchr(p, ';'))) {
497+
p = p2 + 1;
498+
}
499+
} else {
500+
p = new_value;
501+
}
502+
503+
if (PG(safe_mode) && *p && (!php_checkuid(p, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
504+
return FAILURE;
505+
}
506+
507+
if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) {
508+
return FAILURE;
509+
}
510+
}
511+
512+
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
513+
return SUCCESS;
514+
}
515+
482516
PHP_INI_BEGIN()
483517
STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled", "1", PHP_INI_ALL, OnUpdateBool,
484518
cache_enabled, zend_soap_globals, soap_globals)
485-
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateString,
519+
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateCacheDir,
486520
cache_dir, zend_soap_globals, soap_globals)
487521
STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl", "86400", PHP_INI_ALL, OnUpdateLong,
488522
cache_ttl, zend_soap_globals, soap_globals)

0 commit comments

Comments
 (0)