summaryrefslogtreecommitdiff
path: root/sapi/cgi/fastcgi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/cgi/fastcgi.c')
-rw-r--r--sapi/cgi/fastcgi.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 8ddc2e4577..585b6b8e87 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -411,7 +411,7 @@ int fcgi_init(void)
sa_t sa;
socklen_t len = sizeof(sa);
#endif
- zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1);
+ zend_hash_init(&fcgi_mgmt_vars, 8, NULL, fcgi_free_mgmt_var_cb, 1);
fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1);
is_initialized = 1;
@@ -973,7 +973,7 @@ static int fcgi_read_request(fcgi_request *req)
}
} else if (hdr.type == FCGI_GET_VALUES) {
unsigned char *p = buf + sizeof(fcgi_header);
- zval ** value;
+ zval *value;
unsigned int zlen;
fcgi_hash_bucket *q;
@@ -989,10 +989,10 @@ static int fcgi_read_request(fcgi_request *req)
q = req->env.list;
while (q != NULL) {
- if (zend_hash_find(&fcgi_mgmt_vars, q->var, q->var_len, (void**) &value) != SUCCESS) {
+ if ((value = zend_hash_str_find(&fcgi_mgmt_vars, q->var, q->var_len)) == NULL) {
continue;
}
- zlen = Z_STRLEN_PP(value);
+ zlen = Z_STRLEN_P(value);
if ((p + 4 + 4 + q->var_len + zlen) >= (buf + sizeof(buf))) {
break;
}
@@ -1014,7 +1014,7 @@ static int fcgi_read_request(fcgi_request *req)
}
memcpy(p, q->var, q->var_len);
p += q->var_len;
- memcpy(p, Z_STRVAL_PP(value), zlen);
+ memcpy(p, Z_STRVAL_P(value), zlen);
p += zlen;
}
len = p - buf - sizeof(fcgi_header);
@@ -1510,19 +1510,14 @@ void fcgi_impersonate(void)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
- zval * zvalue;
- zvalue = pemalloc(sizeof(*zvalue), 1);
- Z_TYPE_P(zvalue) = IS_STRING;
- Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1);
- Z_STRLEN_P(zvalue) = value_len;
- zend_hash_add(&fcgi_mgmt_vars, name, name_len, &zvalue, sizeof(zvalue), NULL);
+ zval zvalue;
+ ZVAL_NEW_STR(&zvalue, STR_INIT(value, value_len, 1));
+ zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}
-void fcgi_free_mgmt_var_cb(void * ptr)
+void fcgi_free_mgmt_var_cb(zval *zv)
{
- zval ** var = (zval **)ptr;
- pefree(Z_STRVAL_PP(var), 1);
- pefree(*var, 1);
+ pefree(Z_STR_P(zv), 1);
}
/*