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

vbart at nginx.com vbart at nginx.com
Mon Sep 3 12:55:51 UTC 2012


Author: vbart
Date: 2012-09-03 12:55:50 +0000 (Mon, 03 Sep 2012)
New Revision: 4833
URL: http://trac.nginx.org/nginx/changeset/4833/nginx

Log:
Limit req: fix of rbtree node insertion on hash collisions.

The rbtree used in ngx_http_limit_req_module has two level of keys, the top is
hash, and the next is the value string itself. However, when inserting a new
node, only hash has been set, while the value string has been left empty.

The bug was introduced in r4419 (1.1.14).

Found by Charles Chen.


Modified:
   trunk/src/http/modules/ngx_http_limit_req_module.c

Modified: trunk/src/http/modules/ngx_http_limit_req_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_limit_req_module.c	2012-08-30 16:08:13 UTC (rev 4832)
+++ trunk/src/http/modules/ngx_http_limit_req_module.c	2012-09-03 12:55:50 UTC (rev 4833)
@@ -444,17 +444,17 @@
 
     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;



More information about the nginx-devel mailing list