Mercurial > hg > nginx
diff src/core/ngx_hash.c @ 619:7a16e281c01f release-0.3.31
nginx-0.3.31-RELEASE import
*) 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.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 10 Mar 2006 12:51:52 +0000 |
parents | 9262f520ce21 |
children | 5d2b8078c1c2 |
line wrap: on
line diff
--- a/src/core/ngx_hash.c Wed Feb 22 19:41:39 2006 +0000 +++ b/src/core/ngx_hash.c Fri Mar 10 12:51:52 2006 +0000 @@ -741,10 +741,10 @@ 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 @@ * 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 @@ } 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 @@ 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; } return NGX_OK;