a bug in limit_request module

Maxim Dounin mdounin at mdounin.ru
Sat Sep 1 09:24:55 UTC 2012


Hello!

On Wed, Aug 22, 2012 at 06:55:04PM +0400, Valentin V. Bartenev wrote:

> On Wednesday 22 August 2012 17:49:52 chen cw wrote:
> > Hi,
> >        The red-black tree used in limit_request module has two level of
> > keys, the top is hash, and the next is the value string itself. However,
> > when inserting a new node into the tree, only hash is set, the value string
> > is left empty, [...]
> > 
> 
> Nice catch. Thank you.
> 
>  wbr, Valentin V. Bartenev
> 
> 
> Index: src/http/modules/ngx_http_limit_req_module.c
> ===================================================================
> --- src/http/modules/ngx_http_limit_req_module.c        (revision 4826)
> +++ src/http/modules/ngx_http_limit_req_module.c        (working copy)
> @@ -444,17 +444,17 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_limit
>  
>      node->key = hash;
>  
> -    ngx_rbtree_insert(&ctx->sh->rbtree, node);
> -
>      lr = (ngx_http_limit_req_node_t *) &node->color;
>  
> -    ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
> -
>      lr->len = (u_char) len;
>      lr->excess = 0;
>  
>      ngx_memcpy(lr->data, data, len);
>  
> +    ngx_rbtree_insert(&ctx->sh->rbtree, node);
> +
> +    ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
> +
>      if (account) {
>          lr->last = now;
>          lr->count = 0;

Looks fine, please commit.

Maxim Dounin



More information about the nginx-devel mailing list