[nginx] Core: fixed potential division by zero when initializing...
Sergey Kandaurov
pluknet at nginx.com
Thu Aug 13 14:08:07 UTC 2015
details: http://hg.nginx.org/nginx/rev/3b6d69857de2
branches:
changeset: 6225:3b6d69857de2
user: Sergey Kandaurov <pluknet at nginx.com>
date: Thu Aug 13 16:27:17 2015 +0300
description:
Core: fixed potential division by zero when initializing hash.
Found by Clang Static Analyzer.
diffstat:
src/core/ngx_hash.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diffs (18 lines):
diff -r ddf35e019a80 -r 3b6d69857de2 src/core/ngx_hash.c
--- 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_hash_init(ngx_hash_init_t *hinit, ng
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 *))
{
More information about the nginx-devel
mailing list