Browse Source

Update LSAPI to 6.7, added support for 'filter_input'.

Fixed a crash in CLI mode.
pull/870/head
George Wang 12 years ago
parent
commit
bba16dde5d
  1. 68
      sapi/litespeed/lsapi_main.c
  2. 6
      sapi/litespeed/lsapilib.c

68
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 */

6
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] )

Loading…
Cancel
Save