Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r4418 - trunk/src/http/modules

Anonymous User
January 30, 2012 04:28AM
Author: vbart
Date: 2012-01-30 09:26:08 +0000 (Mon, 30 Jan 2012)
New Revision: 4418

Modified:
trunk/src/http/modules/ngx_http_limit_req_module.c
Log:
Limit req: improved error handling when parsing "zone" parameter of
"limit_req_zone" directive; minimum size of zone is increased.

Previously an unsigned variable was used to keep the return value of
ngx_parse_size() function, which led to an incorrect zone size if NGX_ERROR
was returned.

The new code has been taken from the "limit_conn_zone" directive.



Modified: trunk/src/http/modules/ngx_http_limit_req_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_limit_req_module.c 2012-01-30 09:02:29 UTC (rev 4417)
+++ trunk/src/http/modules/ngx_http_limit_req_module.c 2012-01-30 09:26:08 UTC (rev 4418)
@@ -589,7 +589,8 @@
ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
u_char *p;
- size_t size, len;
+ size_t len;
+ ssize_t size;
ngx_str_t *value, name, s;
ngx_int_t rate, scale;
ngx_uint_t i;
@@ -612,25 +613,32 @@

p = (u_char *) ngx_strchr(name.data, ':');

- if (p) {
- *p = '\0';
+ if (p == NULL) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid zone size \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
+ }

- name.len = p - name.data;
+ name.len = p - name.data;

- p++;
+ s.data = p + 1;
+ s.len = value[i].data + value[i].len - s.data;

- s.len = value[i].data + value[i].len - p;
- s.data = p;
+ size = ngx_parse_size(&s);

- size = ngx_parse_size(&s);
- if (size > 8191) {
- continue;
- }
+ if (size == NGX_ERROR) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid zone size \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
}

- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "invalid zone size \"%V\"", &value[i]);
- return NGX_CONF_ERROR;
+ if (size < (ssize_t) (8 * ngx_pagesize)) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "zone \"%V\" is too small", &value[i]);
+ return NGX_CONF_ERROR;
+ }
+
+ continue;
}

if (ngx_strncmp(value[i].data, "rate=", 5) == 0) {
@@ -682,7 +690,7 @@
return NGX_CONF_ERROR;
}

- if (name.len == 0 || size == 0) {
+ if (name.len == 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"%V\" must have \"zone\" parameter",
&cmd->name);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r4418 - trunk/src/http/modules

Anonymous User 1094 January 30, 2012 04:28AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 239
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready