diff options
author | George Wang <gwang@php.net> | 2014-09-03 11:24:45 -0400 |
---|---|---|
committer | George Wang <gwang@php.net> | 2014-09-03 11:29:44 -0400 |
commit | b85b78db4f84a0e5a4fd4d874fe2e7329e7a740e (patch) | |
tree | 88b8d93b6394e7fcc3d012f9d19f3177e5f8a919 /sapi/litespeed | |
parent | 627704b38e0c4ded81fb90524171546d77e2500e (diff) | |
download | php-git-b85b78db4f84a0e5a4fd4d874fe2e7329e7a740e.tar.gz |
Update LSAPI to 6.7, added support for 'filter_input'.
Fixed a crash in CLI mode.
Diffstat (limited to 'sapi/litespeed')
-rw-r--r-- | sapi/litespeed/lsapi_main.c | 68 | ||||
-rw-r--r-- | sapi/litespeed/lsapilib.c | 6 |
2 files changed, 67 insertions, 7 deletions
diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 3413a423ac..cb7c66b44a 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -195,15 +195,22 @@ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC ) /* }}} */ -/* + + static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, void * arg ) { - php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); - return 1; + int filter_arg = (arg == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER; + char * new_val = (char *) pValue; + unsigned int new_val_len; + + if (sapi_module.input_filter(filter_arg, (char *)pKey, &new_val, valLen, &new_val_len TSRMLS_CC)) { + php_register_variable_safe((char *)pKey, new_val, new_val_len, (zval *)arg ); + } + return 1; } -*/ +/* static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, void * arg ) { @@ -222,6 +229,55 @@ static int add_variable( const char * pKey, int keyLen, const char * pValue, int #endif return 1; } +*/ + +static void litespeed_php_import_environment_variables(zval *array_ptr TSRMLS_DC) +{ + char buf[128]; + char **env, *p, *t = buf; + size_t alloc_size = sizeof(buf); + unsigned long nlen; /* ptrdiff_t is not portable */ + + if (PG(http_globals)[TRACK_VARS_ENV] && + array_ptr != PG(http_globals)[TRACK_VARS_ENV] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0 + ) { + zval_dtor(array_ptr); + *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; + } else if (PG(http_globals)[TRACK_VARS_SERVER] && + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0 + ) { + zval_dtor(array_ptr); + *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; + } + + for (env = environ; env != NULL && *env != NULL; env++) { + p = strchr(*env, '='); + if (!p) { /* malformed entry? */ + continue; + } + nlen = p - *env; + if (nlen >= alloc_size) { + alloc_size = nlen + 64; + t = (t == buf ? emalloc(alloc_size): erealloc(t, alloc_size)); + } + memcpy(t, *env, nlen); + t[nlen] = '\0'; + add_variable(t, nlen, p + 1, strlen( p + 1 ), array_ptr TSRMLS_CC); + } + if (t != buf && t != NULL) { + efree(t); + } +} #if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || PHP_MAJOR_VERSION < 5) @@ -268,7 +324,7 @@ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) add_variable_magic_quote("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); } #endif - php_import_environment_variables(track_vars_array TSRMLS_CC); + litespeed_php_import_environment_variables(track_vars_array TSRMLS_CC); } else { php_import_environment_variables(track_vars_array TSRMLS_CC); @@ -370,7 +426,7 @@ static void sapi_lsapi_log_message(char *message TSRMLS_DC) static sapi_module_struct lsapi_sapi_module = { "litespeed", - "LiteSpeed V6.6", + "LiteSpeed V6.7", php_lsapi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 786a3bd20b..aac823fc1c 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -1912,9 +1912,13 @@ int LSAPI_ForeachOrgHeader_r( LSAPI_Request * pReq, int ret; int count = 0; struct _headerInfo headers[512]; + if ( !pReq || !fn ) return -1; - + + if ( !pReq->m_pHeaderIndex ) + return 0; + for( i = 0; i < H_TRANSFER_ENCODING; ++i ) { if ( pReq->m_pHeaderIndex->m_headerOff[i] ) |