Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2015-08-13 16:27:17 +0300
committerSergey Kandaurov <pluknet@nginx.com>2015-08-13 16:27:17 +0300
commitb7da4f5962d617e59f9dda3c953424df9df57d69 (patch)
tree4c8d828b85d4110d1cf0214f3ab679c95de978e3 /src/core/ngx_hash.c
parente161b6a46f14a5eaf0e25cf1525114bc03aa2eab (diff)
Core: fixed potential division by zero when initializing hash.
Found by Clang Static Analyzer.
Diffstat (limited to 'src/core/ngx_hash.c')
-rw-r--r--src/core/ngx_hash.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c
index e58156d55..1a5d0be2e 100644
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -257,6 +257,14 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
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 *))
{