Mercurial > hg > nginx
comparison src/http/modules/ngx_http_limit_req_module.c @ 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 | 21d1e3bcb356 |
children | 00e4459739ed |
comparison
equal
deleted
inserted
replaced
4831:5e3bda6f5208 | 4832:949ea3d3cd1a |
---|---|
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 node->key = hash; | 445 node->key = hash; |
446 | 446 |
447 ngx_rbtree_insert(&ctx->sh->rbtree, node); | |
448 | |
449 lr = (ngx_http_limit_req_node_t *) &node->color; | 447 lr = (ngx_http_limit_req_node_t *) &node->color; |
450 | |
451 ngx_queue_insert_head(&ctx->sh->queue, &lr->queue); | |
452 | 448 |
453 lr->len = (u_char) len; | 449 lr->len = (u_char) len; |
454 lr->excess = 0; | 450 lr->excess = 0; |
455 | 451 |
456 ngx_memcpy(lr->data, data, len); | 452 ngx_memcpy(lr->data, data, len); |
453 | |
454 ngx_rbtree_insert(&ctx->sh->rbtree, node); | |
455 | |
456 ngx_queue_insert_head(&ctx->sh->queue, &lr->queue); | |
457 | 457 |
458 if (account) { | 458 if (account) { |
459 lr->last = now; | 459 lr->last = now; |
460 lr->count = 0; | 460 lr->count = 0; |
461 return NGX_OK; | 461 return NGX_OK; |