changeset 4832:949ea3d3cd1a

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.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 03 Sep 2012 12:55:50 +0000
parents 5e3bda6f5208
children 3464d0b63300
files src/http/modules/ngx_http_limit_req_module.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_limit_req_module.c
+++ b/src/http/modules/ngx_http_limit_req_module.c
@@ -444,17 +444,17 @@ ngx_http_limit_req_lookup(ngx_http_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;