From b2773ab559878238bd024c4bbebe5825cc38ad85 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 22 Jan 2015 12:52:50 +0100 Subject: [PATCH] fix handling of indirect zvals of properties hashtables --- php_http_cookie.c | 14 +++++++------- php_http_env.c | 2 +- php_http_filter.c | 2 +- php_http_message_body.c | 4 ++-- php_http_params.c | 7 +++++-- php_http_querystring.c | 2 +- php_http_url.c | 16 ++++++++-------- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/php_http_cookie.c b/php_http_cookie.c index a43928b..706fc10 100644 --- a/php_http_cookie.c +++ b/php_http_cookie.c @@ -235,16 +235,16 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t ht = HASH_OF(strct); list = php_http_cookie_list_init(list); - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("cookies"))) && Z_TYPE_P(tmp) == IS_ARRAY){ + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("cookies"))) && Z_TYPE_P(tmp) == IS_ARRAY){ array_copy(Z_ARRVAL_P(tmp), &list->cookies); } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("extras"))) && Z_TYPE_P(tmp) == IS_ARRAY){ + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("extras"))) && Z_TYPE_P(tmp) == IS_ARRAY){ array_copy(Z_ARRVAL_P(tmp), &list->extras); } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("flags")))) { + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("flags")))) { list->flags = zval_get_long(tmp); } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("expires")))) { + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("expires")))) { if (Z_TYPE_P(tmp) == IS_LONG) { list->expires = Z_LVAL_P(tmp); } else { @@ -260,7 +260,7 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t zend_string_release(lstr); } } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("max-age")))) { + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("max-age")))) { if (Z_TYPE_P(tmp) == IS_LONG) { list->max_age = Z_LVAL_P(tmp); } else { @@ -274,13 +274,13 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t zend_string_release(lstr); } } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("path")))) { + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("path")))) { zend_string *str = zval_get_string(tmp); list->path = estrndup(str->val, str->len); zend_string_release(str); } - if ((tmp = zend_hash_str_find(ht, ZEND_STRL("domain")))) { + if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("domain")))) { zend_string *str = zval_get_string(tmp); list->domain = estrndup(str->val, str->len); diff --git a/php_http_env.c b/php_http_env.c index 99ea0e0..af00394 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -530,7 +530,7 @@ ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const ch zval *data_ptr; HashTable *ht = HASH_OF(value); - ZEND_HASH_FOREACH_VAL(ht, data_ptr) + ZEND_HASH_FOREACH_VAL_IND(ht, data_ptr) { if (SUCCESS != php_http_env_set_response_header_value(http_code, name_str, name_len, data_ptr, first)) { return FAILURE; diff --git a/php_http_filter.c b/php_http_filter.c index 084d989..f145f02 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -384,7 +384,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int switch (Z_TYPE_P(params)) { case IS_ARRAY: case IS_OBJECT: - if (!(tmp = zend_hash_str_find(HASH_OF(params), ZEND_STRL("flags")))) { + if (!(tmp = zend_hash_str_find_ind(HASH_OF(params), ZEND_STRL("flags")))) { break; } /* no break */ diff --git a/php_http_message_body.c b/php_http_message_body.c index f336f85..5004489 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -340,7 +340,7 @@ static ZEND_RESULT_CODE add_recursive_fields(php_http_message_body_t *body, cons if (!ZEND_HASH_GET_APPLY_COUNT(fields)) { ZEND_HASH_INC_APPLY_COUNT(fields); - ZEND_HASH_FOREACH_KEY_VAL(fields, key.h, key.key, val) + ZEND_HASH_FOREACH_KEY_VAL_IND(fields, key.h, key.key, val) { char *str = format_key(&key, name); @@ -378,7 +378,7 @@ static ZEND_RESULT_CODE add_recursive_files(php_http_message_body_t *body, const if (!ZEND_HASH_GET_APPLY_COUNT(files)) { ZEND_HASH_INC_APPLY_COUNT(files); - ZEND_HASH_FOREACH_KEY_VAL(files, key.h, key.key, val) + ZEND_HASH_FOREACH_KEY_VAL_IND(files, key.h, key.key, val) { if (Z_TYPE_P(val) == IS_ARRAY || Z_TYPE_P(val) == IS_OBJECT) { char *str = format_key(&key, name); diff --git a/php_http_params.c b/php_http_params.c index 74ddf1f..6e5dd4a 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -176,7 +176,7 @@ static void prepare_dimension(php_http_buffer_t *buf, php_http_buffer_t *keybuf, php_http_buffer_init(&prefix); php_http_buffer_append(&prefix, keybuf->data, keybuf->used); - ZEND_HASH_FOREACH_KEY_VAL(ht, key.h, key.key, val) + ZEND_HASH_FOREACH_KEY_VAL_IND(ht, key.h, key.key, val) { if (key.key && !*key.key->val) { /* only public properties */ @@ -724,6 +724,9 @@ static inline void shift_rfc5987(php_http_buffer_t *buf, zval *zvalue, const cha (int) (key.key->len > INT_MAX ? INT_MAX : key.key->len), key.key->val); php_http_arrkey_dtor(&key); + if (Z_TYPE_P(zdata) == IS_INDIRECT) { + zdata = Z_INDIRECT_P(zdata); + } zs = zval_get_string(zdata); ZVAL_STR(&tmp, zs); prepare_value(flags | PHP_HTTP_PARAMS_URLENCODED, &tmp); @@ -770,7 +773,7 @@ static void shift_arg(php_http_buffer_t *buf, char *key_str, size_t key_len, zva if (!rfc5987) { shift_key(buf, key_str, key_len, ass, asl, flags); } - ZEND_HASH_FOREACH_KEY_VAL(ht, key.h, key.key, val) + ZEND_HASH_FOREACH_KEY_VAL_IND(ht, key.h, key.key, val) { /* did you mean recursion? */ php_http_arrkey_stringify(&key, NULL); diff --git a/php_http_querystring.c b/php_http_querystring.c index 0aeb454..bd04f50 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -241,7 +241,7 @@ ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *o ht = Z_ARRVAL(zv); } - ZEND_HASH_FOREACH_KEY_VAL(ht, key.h, key.key, params_entry) + ZEND_HASH_FOREACH_KEY_VAL_IND(ht, key.h, key.key, params_entry) { /* only public properties */ if (!key.key || *key.key->val) { diff --git a/php_http_url.c b/php_http_url.c index 06552be..c4c0e15 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -396,46 +396,46 @@ php_http_url_t *php_http_url_from_struct(HashTable *ht) php_http_buffer_account(&buf, sizeof(php_http_url_t)); memset(buf.data, 0, buf.used); - if ((e = zend_hash_str_find(ht, ZEND_STRL("scheme")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("scheme")))) { zend_string *zs = zval_get_string(e); url(buf)->scheme = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("user")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("user")))) { zend_string *zs = zval_get_string(e); url(buf)->user = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("pass")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("pass")))) { zend_string *zs = zval_get_string(e); url(buf)->pass = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("host")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("host")))) { zend_string *zs = zval_get_string(e); url(buf)->host = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("port")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("port")))) { url(buf)->port = (unsigned short) zval_get_long(e); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("path")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("path")))) { zend_string *zs = zval_get_string(e); url(buf)->path = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("query")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("query")))) { zend_string *zs = zval_get_string(e); url(buf)->query = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); zend_string_release(zs); } - if ((e = zend_hash_str_find(ht, ZEND_STRL("fragment")))) { + if ((e = zend_hash_str_find_ind(ht, ZEND_STRL("fragment")))) { zend_string *zs = zval_get_string(e); url(buf)->fragment = &buf.data[buf.used]; php_http_buffer_append(&buf, zs->val, zs->len + 1); -- 2.30.2