Skip to content

Commit

Permalink
Core: removed unnecessary restriction in hash initialization.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lyokha committed Aug 19, 2021
1 parent 67d2a95 commit 3253b34
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/ngx_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3253b34

Please sign in to comment.