From: Rasmus Lerdorf Date: Wed, 10 May 2006 21:25:01 +0000 (+0000) Subject: MFB input filter hook for getenv() X-Git-Tag: BEFORE_NEW_OUTPUT_API~239 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=839c3e24a3610a29c7e4218e39f1202275927f4e;p=php MFB input filter hook for getenv() --- diff --git a/main/SAPI.c b/main/SAPI.c index d2e8c8ec80..4a5ea83521 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -25,6 +25,7 @@ #include "php.h" #include "SAPI.h" +#include "php_variables.h" #include "php_ini.h" #include "ext/standard/php_string.h" #include "ext/standard/pageinfo.h" @@ -876,11 +877,15 @@ SAPI_API struct stat *sapi_get_stat(TSRMLS_D) SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC) { - if (sapi_module.getenv) { - return sapi_module.getenv(name, name_len TSRMLS_CC); + if (sapi_module.getenv) { + char *value, *tmp = sapi_module.getenv(name, name_len TSRMLS_CC); + if(tmp) value = estrdup(tmp); + else return NULL; + sapi_module.input_filter(PARSE_ENV, name, &value, strlen(value), NULL TSRMLS_CC); + return value; } else { - return NULL; - } + return NULL; + } } SAPI_API int sapi_get_fd(int *fd TSRMLS_DC) diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index ed1434b146..925a0b6cf0 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -250,13 +250,17 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ for (i = 0; i < arr->nelts; i++) { char *val; + int val_len, new_val_len; if (elts[i].val) { val = elts[i].val; } else { val = ""; } - php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC); + val_len = strlen(val); + if (sapi_module.input_filter(PARSE_SERVER, elts[i].key, &val, val_len, &new_val_len TSRMLS_CC)) { + php_register_variable_safe(elts[i].key, val, new_val_len, track_vars_array TSRMLS_CC); + } } /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */