Mercurial > hg > nginx
annotate src/core/ngx_queue.h @ 5418:6961d52ebc49 stable-1.4
Core: fix misallocation at ngx_crypt_apr1 (ticket #412).
Found by using auth_basic.t from mdounin nginx-tests under valgrind.
==10470== Invalid write of size 1
==10470== at 0x43603D: ngx_crypt_to64 (ngx_crypt.c:168)
==10470== by 0x43648E: ngx_crypt (ngx_crypt.c:153)
==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470== by 0x456A91: ngx_http_process_request_line (ngx_http_request.c:964)
==10470== by 0x457097: ngx_http_wait_request_handler (ngx_http_request.c:486)
==10470== by 0x4411EE: ngx_epoll_process_events (ngx_epoll_module.c:691)
==10470== Address 0x5866fab is 0 bytes after a block of size 27 alloc'd
==10470== at 0x4A074CD: malloc (vg_replace_malloc.c:236)
==10470== by 0x43B251: ngx_alloc (ngx_alloc.c:22)
==10470== by 0x421B0D: ngx_malloc (ngx_palloc.c:119)
==10470== by 0x421B65: ngx_pnalloc (ngx_palloc.c:147)
==10470== by 0x436368: ngx_crypt (ngx_crypt.c:140)
==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470==
author | Markus Linnala <Markus.Linnala@cybercom.com> |
---|---|
date | Fri, 20 Sep 2013 17:57:21 +0300 |
parents | d620f497c50f |
children | 3038bd4d7816 |
rev | line source |
---|---|
1646 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
1646 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 | |
11 | |
12 #ifndef _NGX_QUEUE_H_INCLUDED_ | |
13 #define _NGX_QUEUE_H_INCLUDED_ | |
14 | |
15 | |
16 typedef struct ngx_queue_s ngx_queue_t; | |
17 | |
18 struct ngx_queue_s { | |
19 ngx_queue_t *prev; | |
20 ngx_queue_t *next; | |
21 }; | |
22 | |
23 | |
1684 | 24 #define ngx_queue_init(q) \ |
25 (q)->prev = q; \ | |
1763 | 26 (q)->next = q |
1684 | 27 |
28 | |
1646 | 29 #define ngx_queue_empty(h) \ |
30 (h == (h)->prev) | |
31 | |
32 | |
33 #define ngx_queue_insert_head(h, x) \ | |
34 (x)->next = (h)->next; \ | |
35 (x)->next->prev = x; \ | |
36 (x)->prev = h; \ | |
37 (h)->next = x | |
38 | |
39 | |
2026 | 40 #define ngx_queue_insert_after ngx_queue_insert_head |
41 | |
42 | |
43 #define ngx_queue_insert_tail(h, x) \ | |
44 (x)->prev = (h)->prev; \ | |
45 (x)->prev->next = x; \ | |
46 (x)->next = h; \ | |
47 (h)->prev = x | |
48 | |
49 | |
1646 | 50 #define ngx_queue_head(h) \ |
51 (h)->next | |
52 | |
53 | |
54 #define ngx_queue_last(h) \ | |
55 (h)->prev | |
56 | |
57 | |
2026 | 58 #define ngx_queue_sentinel(h) \ |
59 (h) | |
60 | |
61 | |
62 #define ngx_queue_next(q) \ | |
63 (q)->next | |
64 | |
65 | |
66 #define ngx_queue_prev(q) \ | |
67 (q)->prev | |
68 | |
69 | |
1646 | 70 #if (NGX_DEBUG) |
71 | |
72 #define ngx_queue_remove(x) \ | |
73 (x)->next->prev = (x)->prev; \ | |
74 (x)->prev->next = (x)->next; \ | |
75 (x)->prev = NULL; \ | |
76 (x)->next = NULL | |
77 | |
78 #else | |
79 | |
80 #define ngx_queue_remove(x) \ | |
81 (x)->next->prev = (x)->prev; \ | |
82 (x)->prev->next = (x)->next | |
83 | |
84 #endif | |
85 | |
86 | |
2026 | 87 #define ngx_queue_split(h, q, n) \ |
88 (n)->prev = (h)->prev; \ | |
89 (n)->prev->next = n; \ | |
90 (n)->next = q; \ | |
91 (h)->prev = (q)->prev; \ | |
92 (h)->prev->next = h; \ | |
93 (q)->prev = n; | |
94 | |
95 | |
96 #define ngx_queue_add(h, n) \ | |
97 (h)->prev->next = (n)->next; \ | |
98 (n)->next->prev = (h)->prev; \ | |
99 (h)->prev = (n)->prev; \ | |
100 (h)->prev->next = h; | |
101 | |
102 | |
1646 | 103 #define ngx_queue_data(q, type, link) \ |
104 (type *) ((u_char *) q - offsetof(type, link)) | |
105 | |
106 | |
2026 | 107 ngx_queue_t *ngx_queue_middle(ngx_queue_t *queue); |
108 void ngx_queue_sort(ngx_queue_t *queue, | |
109 ngx_int_t (*cmp)(const ngx_queue_t *, const ngx_queue_t *)); | |
110 | |
111 | |
1646 | 112 #endif /* _NGX_QUEUE_H_INCLUDED_ */ |