Mercurial > hg > nginx
changeset 6225:3b6d69857de2
Core: fixed potential division by zero when initializing hash.
Found by Clang Static Analyzer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 13 Aug 2015 16:27:17 +0300 |
parents | ddf35e019a80 |
children | 4bc94faeff66 |
files | src/core/ngx_hash.c |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_hash.c Thu Aug 13 16:27:13 2015 +0300 +++ b/src/core/ngx_hash.c Thu Aug 13 16:27:17 2015 +0300 @@ -257,6 +257,14 @@ ngx_uint_t i, n, key, size, start, bucket_size; ngx_hash_elt_t *elt, **buckets; + if (hinit->max_size == 0) { + ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0, + "could not build %s, you should " + "increase %s_max_size: %i", + hinit->name, hinit->name, hinit->max_size); + return NGX_ERROR; + } + for (n = 0; n < nelts; n++) { if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *)) {