diff options
author | Igor Sysoev <igor@sysoev.ru> | 2006-03-10 15:51:52 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2006-03-10 15:51:52 +0300 |
commit | 13c68741f29943d0ba45f7c9d5a5c4251d5f16f6 (patch) | |
tree | 539580ab05f906419ca310ab8e0d437a1ae7fec8 /src/core/ngx_hash.c | |
parent | 15465ff78e5b53c9fb88dfde0adb8c99f6066892 (diff) |
nginx-0.3.31-RELEASE importrelease-0.3.31
*) Change: now nginx passes the malformed proxied backend responses.
*) Feature: the "listen" directives support the address in the "*:port"
form.
*) Feature: the EVFILER_TIMER support in MacOSX 10.4.
*) Workaround: for MacOSX 64-bit kernel kqueue millisecond timeout
bug.
Thanks to Andrei Nigmatulin.
*) Bugfix: if there were several "listen" directives listening one
various addresses inside one server, then server names like
"*.domain.tld" worked for first address only; the bug had appeared
in 0.3.18.
*) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive
and the request body was in temporarily file then the request was
not transferred.
*) Bugfix: perl 5.8.8 compatibility.
Diffstat (limited to 'src/core/ngx_hash.c')
-rw-r--r-- | src/core/ngx_hash.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c index 1f677c9fa..2876318a3 100644 --- a/src/core/ngx_hash.c +++ b/src/core/ngx_hash.c @@ -741,10 +741,10 @@ ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, ngx_uint_t flags) { size_t len; + u_char *reverse; ngx_str_t *name; ngx_uint_t i, k, n, skip; ngx_hash_key_t *hk; - u_char buf[2048]; if (!(flags & NGX_HASH_WILDCARD_KEY)) { @@ -863,14 +863,19 @@ ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, * and ".example.com" to "com.example\0" */ + reverse = ngx_palloc(ha->temp_pool, key->len); + if (reverse == NULL) { + return NGX_ERROR; + } + len = 0; n = 0; for (i = key->len - 1; i; i--) { if (key->data[i] == '.') { - ngx_memcpy(&buf[n], &key->data[i + 1], len); + ngx_memcpy(&reverse[n], &key->data[i + 1], len); n += len; - buf[n++] = '.'; + reverse[n++] = '.'; len = 0; continue; } @@ -879,11 +884,22 @@ ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, } if (len) { - ngx_memcpy(&buf[n], &key->data[1], len); + ngx_memcpy(&reverse[n], &key->data[1], len); n += len; } - buf[n] = '\0'; + reverse[n] = '\0'; + + + hk = ngx_array_push(&ha->dns_wildcards); + if (hk == NULL) { + return NGX_ERROR; + } + + hk->key.len = key->len - 1; + hk->key.data = reverse; + hk->key_hash = 0; + hk->value = value; /* check conflicts in wildcard hash */ @@ -922,20 +938,8 @@ ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, void *value, if (name->data == NULL) { return NGX_ERROR; } - ngx_memcpy(name->data, key->data + skip, name->len); - - - ngx_memcpy(key->data, buf, key->len); - key->len--; - - hk = ngx_array_push(&ha->dns_wildcards); - if (hk == NULL) { - return NGX_ERROR; - } - hk->key = *key; - hk->key_hash = 0; - hk->value = value; + ngx_memcpy(name->data, key->data + skip, name->len); } return NGX_OK; |