fix handling of indirect zvals of properties hashtables
authorMichael Wallner <mike@php.net>
Thu, 22 Jan 2015 11:52:50 +0000 (12:52 +0100)
committerMichael Wallner <mike@php.net>
Thu, 22 Jan 2015 11:52:50 +0000 (12:52 +0100)
php_http_cookie.c
php_http_env.c
php_http_filter.c
php_http_message_body.c
php_http_params.c
php_http_querystring.c
php_http_url.c

index a43928b833f2f647813a24adedf1d8e4d9188754..706fc10fe2d41a1b12334d9f9c4618337b97f9e0 100644 (file)
@@ -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);
index 99ea0e00f4d8732c8ac7261e480d2d8c1f54b5f8..af0039473eeb02e0e0b96da14857eabee55b3090 100644 (file)
@@ -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;
index 084d98918846ab7a3fd3e1ac2d10c8c68e14d988..f145f02b68a70dbd555483cff72fd4d356552b81 100644 (file)
@@ -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 */
index f336f85c2fa1676973dab191cc3d9a5990263a5b..500448936c7d2a9c3078a18df3e0ce9ce887122b 100644 (file)
@@ -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);
index 74ddf1f8955c2592e2e0f043929aefdd49af190a..6e5dd4a0df442602ca6cd52e882d2a9231fc7086 100644 (file)
@@ -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);
index 0aeb4541d081f8290d5b34b2cbf859b9e52958d2..bd04f5092f9b233a9a53851f75858d4d668c8362 100644 (file)
@@ -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) {
index 06552bed304d6131ddb01c3a5214007abaa3500b..c4c0e15e72293067c1fb0b5433da817bcaf1e0ac 100644 (file)
@@ -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);