# HG changeset patch # User Igor Sysoev # Date 1168534206 0 # Node ID 19118c44303f98450fc47e97ef28abd2cb82e02a # Parent d1792e17a5597da7c723176257cf3b2e86efb31d test length of variable and number of connections diff --git a/src/http/modules/ngx_http_limit_zone_module.c b/src/http/modules/ngx_http_limit_zone_module.c --- a/src/http/modules/ngx_http_limit_zone_module.c +++ b/src/http/modules/ngx_http_limit_zone_module.c @@ -131,9 +131,21 @@ ngx_http_limit_zone_handler(ngx_http_req return NGX_DECLINED; } - r->main->limit_zone_set = 1; + len = vv->len; + + if (len == 0) { + return NGX_DECLINED; + } - len = vv->len; + if (len > 255) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "the value of the \"%V\" variable " + "is more than 255 bytes: \"%V\"", + &ctx->var, vv); + return NGX_DECLINED; + } + + r->main->limit_zone_set = 1; hash = ngx_crc32_short(vv->data, len); @@ -419,6 +431,12 @@ ngx_http_limit_conn(ngx_conf_t *cf, ngx_ return NGX_CONF_ERROR; } + if (n > 65535) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "connection limit must be less 65536"); + return NGX_CONF_ERROR; + } + lzcf->conn = n; return NGX_CONF_OK;