]> git.kaiwu.me - nginx.git/commitdiff
Core: removed unnecessary restriction in hash initialization.
authorAlexey Radkov <alexey.radkov@gmail.com>
Thu, 19 Aug 2021 17:51:27 +0000 (20:51 +0300)
committerAlexey Radkov <alexey.radkov@gmail.com>
Thu, 19 Aug 2021 17:51:27 +0000 (20:51 +0300)
Hash initialization ignores elements with key.data set to NULL.
Nevertheless, the initial hash bucket size check didn't skip them,
resulting in unnecessary restrictions on, for example, variables with
long names and with the NGX_HTTP_VARIABLE_NOHASH flag.

Fix is to update the initial hash bucket size check to skip elements
with key.data set to NULL, similarly to how it is done in other parts
of the code.

src/core/ngx_hash.c

index d9c157c1dc7e47f9e0cd5173c5a373edd2c3f865..8215c2717b26051e31901d2bce49e5b5ce7104ae 100644 (file)
@@ -274,6 +274,10 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
     }
 
     for (n = 0; n < nelts; n++) {
+        if (names[n].key.data == NULL) {
+            continue;
+        }
+
         if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *))
         {
             ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0,