*) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
Igor Sysoev
14 years ago
825 | 825 | |
826 | 826 | ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT); |
827 | 827 | |
828 | ccf->oldpid.data = ngx_palloc(cycle->pool, ccf->oldpid.len); | |
828 | ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len); | |
829 | 829 | if (ccf->oldpid.data == NULL) { |
830 | 830 | return NGX_CONF_ERROR; |
831 | 831 | } |
869 | 869 | |
870 | 870 | } else { |
871 | 871 | cycle->lock_file.len = ccf->lock_file.len + 1; |
872 | cycle->lock_file.data = ngx_palloc(cycle->pool, | |
872 | cycle->lock_file.data = ngx_pnalloc(cycle->pool, | |
873 | 873 | ccf->lock_file.len + sizeof(".accept")); |
874 | 874 | if (cycle->lock_file.data == NULL) { |
875 | 875 | return NGX_CONF_ERROR; |
38 | 38 | |
39 | 39 | p = a->pool; |
40 | 40 | |
41 | if ((u_char *) a->elts + a->size * a->nalloc == p->last) { | |
42 | p->last -= a->size * a->nalloc; | |
41 | if ((u_char *) a->elts + a->size * a->nalloc == p->d.last) { | |
42 | p->d.last -= a->size * a->nalloc; | |
43 | 43 | } |
44 | 44 | |
45 | if ((u_char *) a + sizeof(ngx_array_t) == p->last) { | |
46 | p->last = (u_char *) a; | |
45 | if ((u_char *) a + sizeof(ngx_array_t) == p->d.last) { | |
46 | p->d.last = (u_char *) a; | |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
63 | 63 | |
64 | 64 | p = a->pool; |
65 | 65 | |
66 | if ((u_char *) a->elts + size == p->last && p->last + a->size <= p->end) | |
66 | if ((u_char *) a->elts + size == p->d.last | |
67 | && p->d.last + a->size <= p->d.end) | |
67 | 68 | { |
68 | 69 | /* |
69 | 70 | * the array allocation is the last in the pool |
70 | 71 | * and there is space for new allocation |
71 | 72 | */ |
72 | 73 | |
73 | p->last += a->size; | |
74 | p->d.last += a->size; | |
74 | 75 | a->nalloc++; |
75 | 76 | |
76 | 77 | } else { |
110 | 111 | |
111 | 112 | p = a->pool; |
112 | 113 | |
113 | if ((u_char *) a->elts + a->size * a->nalloc == p->last | |
114 | && p->last + size <= p->end) | |
114 | if ((u_char *) a->elts + a->size * a->nalloc == p->d.last | |
115 | && p->d.last + size <= p->d.end) | |
115 | 116 | { |
116 | 117 | /* |
117 | 118 | * the array allocation is the last in the pool |
118 | 119 | * and there is space for new allocation |
119 | 120 | */ |
120 | 121 | |
121 | p->last += size; | |
122 | p->d.last += size; | |
122 | 123 | a->nalloc += n; |
123 | 124 | |
124 | 125 | } else { |
573 | 573 | return NGX_ERROR; |
574 | 574 | } |
575 | 575 | |
576 | word->data = ngx_palloc(cf->pool, b->pos - start + 1); | |
576 | word->data = ngx_pnalloc(cf->pool, b->pos - start + 1); | |
577 | 577 | if (word->data == NULL) { |
578 | 578 | return NGX_ERROR; |
579 | 579 | } |
725 | 725 | } |
726 | 726 | |
727 | 727 | name->len = len + old.len; |
728 | name->data = ngx_palloc(cycle->pool, name->len + 1); | |
728 | name->data = ngx_pnalloc(cycle->pool, name->len + 1); | |
729 | 729 | if (name->data == NULL) { |
730 | 730 | return NGX_ERROR; |
731 | 731 | } |
35 | 35 | sin->sin_port = htons(port); |
36 | 36 | |
37 | 37 | |
38 | ls->addr_text.data = ngx_palloc(cf->pool, | |
38 | ls->addr_text.data = ngx_pnalloc(cf->pool, | |
39 | 39 | INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); |
40 | 40 | if (ls->addr_text.data == NULL) { |
41 | 41 | return NULL; |
105 | 105 | |
106 | 106 | ls[i].addr_text_max_len = INET_ADDRSTRLEN; |
107 | 107 | |
108 | ls[i].addr_text.data = ngx_palloc(cycle->pool, INET_ADDRSTRLEN - 1 | |
109 | + sizeof(":65535") - 1); | |
108 | ls[i].addr_text.data = ngx_pnalloc(cycle->pool, | |
109 | INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); | |
110 | 110 | if (ls[i].addr_text.data == NULL) { |
111 | 111 | return NGX_ERROR; |
112 | 112 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | cycle->conf_file.len = old_cycle->conf_file.len; |
83 | cycle->conf_file.data = ngx_palloc(pool, old_cycle->conf_file.len + 1); | |
83 | cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1); | |
84 | 84 | if (cycle->conf_file.data == NULL) { |
85 | 85 | ngx_destroy_pool(pool); |
86 | 86 | return NULL; |
181 | 181 | hostname[NGX_MAXHOSTNAMELEN - 1] = '\0'; |
182 | 182 | cycle->hostname.len = ngx_strlen(hostname); |
183 | 183 | |
184 | cycle->hostname.data = ngx_palloc(pool, cycle->hostname.len); | |
184 | cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len); | |
185 | 185 | if (cycle->hostname.data == NULL) { |
186 | 186 | ngx_destroy_pool(pool); |
187 | 187 | return NULL; |
459 | 459 | |
460 | 460 | #else |
461 | 461 | |
462 | lock_file = ngx_palloc(cycle->pool, | |
463 | cycle->lock_file.len + shm_zone[i].name.len); | |
462 | lock_file = ngx_pnalloc(cycle->pool, | |
463 | cycle->lock_file.len + shm_zone[i].name.len); | |
464 | 464 | |
465 | 465 | if (lock_file == NULL) { |
466 | 466 | goto failed; |
45 | 45 | |
46 | 46 | file->name.len = path->name.len + 1 + path->len + 10; |
47 | 47 | |
48 | file->name.data = ngx_palloc(pool, file->name.len + 1); | |
48 | file->name.data = ngx_pnalloc(pool, file->name.len + 1); | |
49 | 49 | if (file->name.data == NULL) { |
50 | 50 | return NGX_ERROR; |
51 | 51 | } |
838 | 838 | } |
839 | 839 | |
840 | 840 | name->len = last - 1; |
841 | name->data = ngx_palloc(ha->temp_pool, name->len); | |
841 | name->data = ngx_pnalloc(ha->temp_pool, name->len); | |
842 | 842 | if (name->data == NULL) { |
843 | 843 | return NGX_ERROR; |
844 | 844 | } |
854 | 854 | * and ".example.com" to "com.example\0" |
855 | 855 | */ |
856 | 856 | |
857 | p = ngx_palloc(ha->temp_pool, last); | |
857 | p = ngx_pnalloc(ha->temp_pool, last); | |
858 | 858 | if (p == NULL) { |
859 | 859 | return NGX_ERROR; |
860 | 860 | } |
890 | 890 | |
891 | 891 | last++; |
892 | 892 | |
893 | p = ngx_palloc(ha->temp_pool, last); | |
893 | p = ngx_pnalloc(ha->temp_pool, last); | |
894 | 894 | if (p == NULL) { |
895 | 895 | return NGX_ERROR; |
896 | 896 | } |
943 | 943 | } |
944 | 944 | |
945 | 945 | name->len = last - skip; |
946 | name->data = ngx_palloc(ha->temp_pool, name->len); | |
946 | name->data = ngx_pnalloc(ha->temp_pool, name->len); | |
947 | 947 | if (name->data == NULL) { |
948 | 948 | return NGX_ERROR; |
949 | 949 | } |
577 | 577 | |
578 | 578 | len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1; |
579 | 579 | |
580 | p = ngx_palloc(pool, len); | |
580 | p = ngx_pnalloc(pool, len); | |
581 | 581 | if (p == NULL) { |
582 | 582 | return NGX_ERROR; |
583 | 583 | } |
613 | 613 | u->addrs[0].sockaddr = (struct sockaddr *) sin; |
614 | 614 | u->addrs[0].socklen = sizeof(struct sockaddr_in); |
615 | 615 | |
616 | p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1); | |
616 | p = ngx_pnalloc(pool, u->host.len + sizeof(":65536") - 1); | |
617 | 617 | if (p == NULL) { |
618 | 618 | return NGX_ERROR; |
619 | 619 | } |
7 | 7 | #include <ngx_core.h> |
8 | 8 | |
9 | 9 | |
10 | static void *ngx_palloc_block(ngx_pool_t *pool, size_t size); | |
11 | static void *ngx_palloc_large(ngx_pool_t *pool, size_t size); | |
12 | ||
13 | ||
10 | 14 | ngx_pool_t * |
11 | 15 | ngx_create_pool(size_t size, ngx_log_t *log) |
12 | 16 | { |
17 | 21 | return NULL; |
18 | 22 | } |
19 | 23 | |
20 | p->last = (u_char *) p + sizeof(ngx_pool_t); | |
21 | p->end = (u_char *) p + size; | |
24 | p->d.last = (u_char *) p + sizeof(ngx_pool_t); | |
25 | p->d.end = (u_char *) p + size; | |
26 | p->d.next = NULL; | |
27 | ||
28 | p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size - sizeof(ngx_pool_t): | |
29 | NGX_MAX_ALLOC_FROM_POOL; | |
22 | 30 | p->current = p; |
23 | 31 | p->chain = NULL; |
24 | p->next = NULL; | |
25 | 32 | p->large = NULL; |
26 | 33 | p->cleanup = NULL; |
27 | 34 | p->log = log; |
61 | 68 | * so we can not use this log while the free()ing the pool |
62 | 69 | */ |
63 | 70 | |
64 | for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { | |
71 | for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) { | |
65 | 72 | ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
66 | "free: %p, unused: %uz", p, p->end - p->last); | |
73 | "free: %p, unused: %uz", p, p->d.end - p->d.last); | |
67 | 74 | |
68 | 75 | if (n == NULL) { |
69 | 76 | break; |
72 | 79 | |
73 | 80 | #endif |
74 | 81 | |
75 | for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { | |
82 | for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) { | |
76 | 83 | ngx_free(p); |
77 | 84 | |
78 | 85 | if (n == NULL) { |
85 | 92 | void * |
86 | 93 | ngx_palloc(ngx_pool_t *pool, size_t size) |
87 | 94 | { |
88 | u_char *m; | |
89 | ngx_pool_t *p, *n, *current; | |
90 | ngx_pool_large_t *large; | |
91 | ||
92 | if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL | |
93 | && size <= (size_t) (pool->end - (u_char *) pool) | |
94 | - (size_t) ngx_align_ptr(sizeof(ngx_pool_t), NGX_ALIGNMENT)) | |
95 | { | |
95 | u_char *m; | |
96 | ngx_pool_t *p; | |
97 | ||
98 | if (size <= pool->max) { | |
99 | ||
96 | 100 | p = pool->current; |
97 | current = p; | |
98 | ||
99 | for ( ;; ) { | |
100 | ||
101 | /* | |
102 | * allow non-aligned memory blocks for small allocations (1, 2, | |
103 | * or 3 bytes) and for odd length strings (struct's have aligned | |
104 | * size) | |
105 | */ | |
106 | ||
107 | if (size < sizeof(int) || (size & 1)) { | |
108 | m = p->last; | |
109 | ||
110 | } else { | |
111 | m = ngx_align_ptr(p->last, NGX_ALIGNMENT); | |
112 | } | |
113 | ||
114 | if ((size_t) (p->end - m) >= size) { | |
115 | p->last = m + size; | |
101 | ||
102 | do { | |
103 | m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT); | |
104 | ||
105 | if ((size_t) (p->d.end - m) >= size) { | |
106 | p->d.last = m + size; | |
116 | 107 | |
117 | 108 | return m; |
118 | 109 | } |
119 | 110 | |
120 | if ((size_t) (p->end - m) < NGX_ALIGNMENT) { | |
121 | current = p->next; | |
111 | p = p->d.next; | |
112 | ||
113 | } while (p); | |
114 | ||
115 | return ngx_palloc_block(pool, size); | |
116 | } | |
117 | ||
118 | return ngx_palloc_large(pool, size); | |
119 | } | |
120 | ||
121 | ||
122 | void * | |
123 | ngx_pnalloc(ngx_pool_t *pool, size_t size) | |
124 | { | |
125 | u_char *m; | |
126 | ngx_pool_t *p; | |
127 | ||
128 | if (size <= pool->max) { | |
129 | ||
130 | p = pool->current; | |
131 | ||
132 | do { | |
133 | m = p->d.last; | |
134 | ||
135 | if ((size_t) (p->d.end - m) >= size) { | |
136 | p->d.last = m + size; | |
137 | ||
138 | return m; | |
122 | 139 | } |
123 | 140 | |
124 | if (p->next == NULL) { | |
125 | break; | |
126 | } | |
127 | ||
128 | p = p->next; | |
129 | pool->current = current; | |
130 | } | |
131 | ||
132 | /* allocate a new pool block */ | |
133 | ||
134 | n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log); | |
135 | if (n == NULL) { | |
136 | return NULL; | |
137 | } | |
138 | ||
139 | pool->current = current ? current : n; | |
140 | ||
141 | p->next = n; | |
142 | m = ngx_align_ptr(n->last, NGX_ALIGNMENT); | |
143 | n->last = m + size; | |
144 | ||
145 | return m; | |
146 | } | |
141 | p = p->d.next; | |
142 | ||
143 | } while (p); | |
144 | ||
145 | return ngx_palloc_block(pool, size); | |
146 | } | |
147 | ||
148 | return ngx_palloc_large(pool, size); | |
149 | } | |
150 | ||
151 | ||
152 | static void * | |
153 | ngx_palloc_block(ngx_pool_t *pool, size_t size) | |
154 | { | |
155 | u_char *m; | |
156 | ngx_pool_t *p, *new, *current; | |
157 | ||
158 | new = ngx_create_pool((size_t) (pool->d.end - (u_char *) pool), pool->log); | |
159 | if (new == NULL) { | |
160 | return NULL; | |
161 | } | |
162 | ||
163 | current = pool->current; | |
164 | ||
165 | for (p = current; p->d.next; p = p->d.next) { | |
166 | if ((size_t) (p->d.end - p->d.last) < NGX_ALIGNMENT) { | |
167 | current = p->d.next; | |
168 | } | |
169 | } | |
170 | ||
171 | p->d.next = new; | |
172 | ||
173 | pool->current = current ? current : new; | |
174 | ||
175 | m = (u_char *) new + sizeof(ngx_pool_data_t); | |
176 | new->d.last = m + size; | |
177 | ||
178 | return m; | |
179 | } | |
180 | ||
181 | ||
182 | static void * | |
183 | ngx_palloc_large(ngx_pool_t *pool, size_t size) | |
184 | { | |
185 | void *p; | |
186 | ngx_pool_large_t *large; | |
147 | 187 | |
148 | 188 | #if 0 |
149 | 189 | p = ngx_memalign(ngx_pagesize, size, pool->log); |
168 | 208 | pool->large = large; |
169 | 209 | |
170 | 210 | return p; |
171 | } | |
172 | ||
173 | ||
174 | void * | |
175 | ngx_palloc_aligned(ngx_pool_t *pool, size_t size) | |
176 | { | |
177 | if (size & 1) { | |
178 | size++; | |
179 | } | |
180 | ||
181 | return ngx_palloc(pool, size); | |
182 | 211 | } |
183 | 212 | |
184 | 213 |
42 | 42 | }; |
43 | 43 | |
44 | 44 | |
45 | struct ngx_pool_s { | |
45 | typedef struct { | |
46 | 46 | u_char *last; |
47 | 47 | u_char *end; |
48 | ngx_pool_t *next; | |
49 | } ngx_pool_data_t; | |
50 | ||
51 | ||
52 | struct ngx_pool_s { | |
53 | ngx_pool_data_t d; | |
54 | size_t max; | |
48 | 55 | ngx_pool_t *current; |
49 | 56 | ngx_chain_t *chain; |
50 | ngx_pool_t *next; | |
51 | 57 | ngx_pool_large_t *large; |
52 | 58 | ngx_pool_cleanup_t *cleanup; |
53 | 59 | ngx_log_t *log; |
68 | 74 | void ngx_destroy_pool(ngx_pool_t *pool); |
69 | 75 | |
70 | 76 | void *ngx_palloc(ngx_pool_t *pool, size_t size); |
71 | void *ngx_palloc_aligned(ngx_pool_t *pool, size_t size); | |
77 | void *ngx_pnalloc(ngx_pool_t *pool, size_t size); | |
72 | 78 | void *ngx_pcalloc(ngx_pool_t *pool, size_t size); |
73 | 79 | ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p); |
74 | 80 |
164 | 164 | #endif |
165 | 165 | |
166 | 166 | if (pool) { |
167 | return ngx_palloc_aligned(pool, size); | |
167 | return ngx_palloc(pool, size); | |
168 | 168 | } |
169 | 169 | |
170 | 170 | return NULL; |
33 | 33 | { |
34 | 34 | u_char *dst; |
35 | 35 | |
36 | dst = ngx_palloc(pool, src->len); | |
36 | dst = ngx_pnalloc(pool, src->len); | |
37 | 37 | if (dst == NULL) { |
38 | 38 | return NULL; |
39 | 39 | } |
200 | 200 | #endif |
201 | 201 | |
202 | 202 | if (ls->addr_ntop) { |
203 | c->addr_text.data = ngx_palloc(c->pool, ls->addr_text_max_len); | |
203 | c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len); | |
204 | 204 | if (c->addr_text.data == NULL) { |
205 | 205 | ngx_close_accepted_connection(c); |
206 | 206 | return; |
57 | 57 | } |
58 | 58 | |
59 | 59 | if (c->listening->addr_ntop) { |
60 | c->addr_text.data = ngx_palloc(c->pool, | |
61 | c->listening->addr_text_max_len); | |
60 | c->addr_text.data = ngx_pnalloc(c->pool, | |
61 | c->listening->addr_text_max_len); | |
62 | 62 | if (c->addr_text.data == NULL) { |
63 | 63 | /* TODO: close socket */ |
64 | 64 | return; |
1906 | 1906 | len = BIO_pending(bio); |
1907 | 1907 | s->len = len; |
1908 | 1908 | |
1909 | s->data = ngx_palloc(pool, len); | |
1909 | s->data = ngx_pnalloc(pool, len); | |
1910 | 1910 | if (s->data == NULL) { |
1911 | 1911 | goto failed; |
1912 | 1912 | } |
1953 | 1953 | for (len = 0; p[len]; len++) { /* void */ } |
1954 | 1954 | |
1955 | 1955 | s->len = len; |
1956 | s->data = ngx_palloc(pool, len); | |
1956 | s->data = ngx_pnalloc(pool, len); | |
1957 | 1957 | if (s->data == NULL) { |
1958 | 1958 | OPENSSL_free(p); |
1959 | 1959 | X509_free(cert); |
1995 | 1995 | for (len = 0; p[len]; len++) { /* void */ } |
1996 | 1996 | |
1997 | 1997 | s->len = len; |
1998 | s->data = ngx_palloc(pool, len); | |
1998 | s->data = ngx_pnalloc(pool, len); | |
1999 | 1999 | if (s->data == NULL) { |
2000 | 2000 | OPENSSL_free(p); |
2001 | 2001 | X509_free(cert); |
2035 | 2035 | len = BIO_pending(bio); |
2036 | 2036 | |
2037 | 2037 | s->len = len; |
2038 | s->data = ngx_palloc(pool, len); | |
2038 | s->data = ngx_pnalloc(pool, len); | |
2039 | 2039 | if (s->data == NULL) { |
2040 | 2040 | BIO_free(bio); |
2041 | 2041 | X509_free(cert); |
231 | 231 | |
232 | 232 | if (state == sw_passwd) { |
233 | 233 | pwd.len = i - passwd; |
234 | pwd.data = ngx_palloc(r->pool, pwd.len + 1); | |
234 | pwd.data = ngx_pnalloc(r->pool, pwd.len + 1); | |
235 | 235 | if (pwd.data == NULL) { |
236 | 236 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
237 | 237 | } |
399 | 399 | |
400 | 400 | len = sizeof("Basic realm=\"") - 1 + realm->len + 1; |
401 | 401 | |
402 | basic = ngx_palloc(cf->pool, len); | |
402 | basic = ngx_pnalloc(cf->pool, len); | |
403 | 403 | if (basic == NULL) { |
404 | 404 | return NGX_CONF_ERROR; |
405 | 405 | } |
281 | 281 | allocated = path.len + 1 + len + 1 |
282 | 282 | + NGX_HTTP_AUTOINDEX_PREALLOCATE; |
283 | 283 | |
284 | filename = ngx_palloc(pool, allocated); | |
284 | filename = ngx_pnalloc(pool, allocated); | |
285 | 285 | if (filename == NULL) { |
286 | 286 | return ngx_http_autoindex_error(r, &dir, &path); |
287 | 287 | } |
317 | 317 | |
318 | 318 | entry->name.len = len; |
319 | 319 | |
320 | entry->name.data = ngx_palloc(pool, len + 1); | |
320 | entry->name.data = ngx_pnalloc(pool, len + 1); | |
321 | 321 | if (entry->name.data == NULL) { |
322 | 322 | return ngx_http_autoindex_error(r, &dir, &path); |
323 | 323 | } |
1101 | 1101 | location = path + clcf->root.len; |
1102 | 1102 | |
1103 | 1103 | } else { |
1104 | location = ngx_palloc(r->pool, r->uri.len); | |
1104 | location = ngx_pnalloc(r->pool, r->uri.len); | |
1105 | 1105 | if (location == NULL) { |
1106 | 1106 | return NGX_ERROR; |
1107 | 1107 | } |
1058 | 1058 | size += part[i].end - part[i].start; |
1059 | 1059 | } |
1060 | 1060 | |
1061 | p = ngx_palloc(r->pool, size); | |
1061 | p = ngx_pnalloc(r->pool, size); | |
1062 | 1062 | if (p == NULL) { |
1063 | 1063 | return NGX_ERROR; |
1064 | 1064 | } |
1086 | 1086 | h->value.data = r->header_start; |
1087 | 1087 | h->value.data[h->value.len] = '\0'; |
1088 | 1088 | |
1089 | h->lowcase_key = ngx_palloc(r->pool, h->key.len); | |
1089 | h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); | |
1090 | 1090 | if (h->lowcase_key == NULL) { |
1091 | 1091 | return NGX_ERROR; |
1092 | 1092 | } |
1096 | 1096 | h->key.len = r->header_name_end - r->header_name_start; |
1097 | 1097 | h->value.len = r->header_end - r->header_start; |
1098 | 1098 | |
1099 | h->key.data = ngx_palloc(r->pool, | |
1100 | h->key.len + 1 + h->value.len + 1 | |
1101 | + h->key.len); | |
1099 | h->key.data = ngx_pnalloc(r->pool, | |
1100 | h->key.len + 1 + h->value.len + 1 | |
1101 | + h->key.len); | |
1102 | 1102 | if (h->key.data == NULL) { |
1103 | 1103 | return NGX_ERROR; |
1104 | 1104 | } |
2014 | 2014 | |
2015 | 2015 | v->len = r->uri.len + flcf->index.len; |
2016 | 2016 | |
2017 | v->data = ngx_palloc(r->pool, v->len); | |
2017 | v->data = ngx_pnalloc(r->pool, v->len); | |
2018 | 2018 | if (v->data == NULL) { |
2019 | 2019 | return NGX_ERROR; |
2020 | 2020 | } |
801 | 801 | return NGX_OK; |
802 | 802 | } |
803 | 803 | |
804 | v->data = ngx_palloc(r->pool, NGX_INT32_LEN + 3); | |
804 | v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3); | |
805 | 805 | if (v->data == NULL) { |
806 | 806 | return NGX_ERROR; |
807 | 807 | } |
950 | 950 | |
951 | 951 | type->len = value[i].len; |
952 | 952 | |
953 | type->data = ngx_palloc(cf->pool, type->len + 1); | |
953 | type->data = ngx_pnalloc(cf->pool, type->len + 1); | |
954 | 954 | if (type->data == NULL) { |
955 | 955 | return NGX_CONF_ERROR; |
956 | 956 | } |
263 | 263 | return NGX_OK; |
264 | 264 | } |
265 | 265 | |
266 | expires->value.data = ngx_palloc(r->pool, len); | |
266 | expires->value.data = ngx_pnalloc(r->pool, len); | |
267 | 267 | if (expires->value.data == NULL) { |
268 | 268 | return NGX_ERROR; |
269 | 269 | } |
296 | 296 | return NGX_OK; |
297 | 297 | } |
298 | 298 | |
299 | cc->value.data = ngx_palloc(r->pool, | |
300 | sizeof("max-age=") + NGX_TIME_T_LEN + 1); | |
299 | cc->value.data = ngx_pnalloc(r->pool, | |
300 | sizeof("max-age=") + NGX_TIME_T_LEN + 1); | |
301 | 301 | if (cc->value.data == NULL) { |
302 | 302 | return NGX_ERROR; |
303 | 303 | } |
253 | 253 | uri.data = path.data + root; |
254 | 254 | |
255 | 255 | } else { |
256 | uri.data = ngx_palloc(r->pool, uri.len); | |
256 | uri.data = ngx_pnalloc(r->pool, uri.len); | |
257 | 257 | if (uri.data == NULL) { |
258 | 258 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | line = ngx_palloc(r->pool, len); | |
263 | line = ngx_pnalloc(r->pool, len); | |
264 | 264 | if (line == NULL) { |
265 | 265 | return NGX_ERROR; |
266 | 266 | } |
969 | 969 | } else { |
970 | 970 | op->run = ngx_http_log_copy_long; |
971 | 971 | |
972 | p = ngx_palloc(cf->pool, len); | |
972 | p = ngx_pnalloc(cf->pool, len); | |
973 | 973 | if (p == NULL) { |
974 | 974 | return NGX_CONF_ERROR; |
975 | 975 | } |
129 | 129 | return NGX_OK; |
130 | 130 | } |
131 | 131 | |
132 | name = ngx_palloc(r->pool, len); | |
132 | name = ngx_pnalloc(r->pool, len); | |
133 | 133 | if (name == NULL) { |
134 | 134 | return NGX_ERROR; |
135 | 135 | } |
963 | 963 | u->state->status = ctx->status; |
964 | 964 | |
965 | 965 | u->headers_in.status_line.len = ctx->status_end - ctx->status_start; |
966 | u->headers_in.status_line.data = ngx_palloc(r->pool, | |
967 | u->headers_in.status_line.len); | |
966 | u->headers_in.status_line.data = ngx_pnalloc(r->pool, | |
967 | u->headers_in.status_line.len); | |
968 | 968 | if (u->headers_in.status_line.data == NULL) { |
969 | 969 | return NGX_ERROR; |
970 | 970 | } |
1219 | 1219 | h->key.len = r->header_name_end - r->header_name_start; |
1220 | 1220 | h->value.len = r->header_end - r->header_start; |
1221 | 1221 | |
1222 | h->key.data = ngx_palloc(r->pool, | |
1222 | h->key.data = ngx_pnalloc(r->pool, | |
1223 | 1223 | h->key.len + 1 + h->value.len + 1 + h->key.len); |
1224 | 1224 | if (h->key.data == NULL) { |
1225 | 1225 | return NGX_ERROR; |
1399 | 1399 | v->len = r->headers_in.x_forwarded_for->value.len |
1400 | 1400 | + sizeof(", ") - 1 + r->connection->addr_text.len; |
1401 | 1401 | |
1402 | p = ngx_palloc(r->pool, v->len); | |
1402 | p = ngx_pnalloc(r->pool, v->len); | |
1403 | 1403 | if (p == NULL) { |
1404 | 1404 | return NGX_ERROR; |
1405 | 1405 | } |
1434 | 1434 | v->no_cacheable = 0; |
1435 | 1435 | v->not_found = 0; |
1436 | 1436 | |
1437 | v->data = ngx_palloc(r->connection->pool, NGX_SIZE_T_LEN); | |
1437 | v->data = ngx_pnalloc(r->connection->pool, NGX_SIZE_T_LEN); | |
1438 | 1438 | |
1439 | 1439 | if (v->data == NULL) { |
1440 | 1440 | return NGX_ERROR; |
1491 | 1491 | |
1492 | 1492 | len = prefix + pr->replacement.text.len + h->value.len - pr->redirect.len; |
1493 | 1493 | |
1494 | data = ngx_palloc(r->pool, len); | |
1494 | data = ngx_pnalloc(r->pool, len); | |
1495 | 1495 | if (data == NULL) { |
1496 | 1496 | return NGX_ERROR; |
1497 | 1497 | } |
1543 | 1543 | len += lcode(&e); |
1544 | 1544 | } |
1545 | 1545 | |
1546 | data = ngx_palloc(r->pool, len); | |
1546 | data = ngx_pnalloc(r->pool, len); | |
1547 | 1547 | if (data == NULL) { |
1548 | 1548 | return NGX_ERROR; |
1549 | 1549 | } |
306 | 306 | content_range->key.len = sizeof("Content-Range") - 1; |
307 | 307 | content_range->key.data = (u_char *) "Content-Range"; |
308 | 308 | |
309 | content_range->value.data = ngx_palloc(r->pool, | |
309 | content_range->value.data = ngx_pnalloc(r->pool, | |
310 | 310 | sizeof("bytes */") - 1 + NGX_OFF_T_LEN); |
311 | 311 | if (content_range->value.data == NULL) { |
312 | 312 | return NGX_ERROR; |
340 | 340 | content_range->key.data = (u_char *) "Content-Range"; |
341 | 341 | |
342 | 342 | content_range->value.data = |
343 | ngx_palloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN); | |
343 | ngx_pnalloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN); | |
344 | 344 | if (content_range->value.data == NULL) { |
345 | 345 | return NGX_ERROR; |
346 | 346 | } |
375 | 375 | len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
376 | 376 | } |
377 | 377 | |
378 | ctx->boundary_header.data = ngx_palloc(r->pool, len); | |
378 | ctx->boundary_header.data = ngx_pnalloc(r->pool, len); | |
379 | 379 | if (ctx->boundary_header.data == NULL) { |
380 | 380 | return NGX_ERROR; |
381 | 381 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | r->headers_out.content_type.data = |
416 | ngx_palloc(r->pool, | |
417 | sizeof("Content-Type: multipart/byteranges; boundary=") - 1 | |
418 | + NGX_ATOMIC_T_LEN); | |
416 | ngx_pnalloc(r->pool, | |
417 | sizeof("Content-Type: multipart/byteranges; boundary=") - 1 | |
418 | + NGX_ATOMIC_T_LEN); | |
419 | 419 | |
420 | 420 | if (r->headers_out.content_type.data == NULL) { |
421 | 421 | return NGX_ERROR; |
440 | 440 | /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */ |
441 | 441 | |
442 | 442 | range[i].content_range.data = |
443 | ngx_palloc(r->pool, 3 * NGX_OFF_T_LEN + 2 + 4); | |
443 | ngx_pnalloc(r->pool, 3 * NGX_OFF_T_LEN + 2 + 4); | |
444 | 444 | |
445 | 445 | if (range[i].content_range.data == NULL) { |
446 | 446 | return NGX_ERROR; |
648 | 648 | b->temporary = 1; |
649 | 649 | b->last_buf = 1; |
650 | 650 | |
651 | b->pos = ngx_palloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN | |
652 | + sizeof("--" CRLF) - 1); | |
651 | b->pos = ngx_pnalloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN | |
652 | + sizeof("--" CRLF) - 1); | |
653 | 653 | if (b->pos == NULL) { |
654 | 654 | return NGX_ERROR; |
655 | 655 | } |
162 | 162 | return NGX_DECLINED; |
163 | 163 | } |
164 | 164 | |
165 | p = ngx_palloc(r->connection->pool, len); | |
165 | p = ngx_pnalloc(r->connection->pool, len); | |
166 | 166 | if (p == NULL) { |
167 | 167 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
168 | 168 | } |
1150 | 1150 | |
1151 | 1151 | default: |
1152 | 1152 | ctx->command.len = 1; |
1153 | ctx->command.data = ngx_palloc(r->pool, | |
1154 | NGX_HTTP_SSI_COMMAND_LEN); | |
1153 | ctx->command.data = ngx_pnalloc(r->pool, | |
1154 | NGX_HTTP_SSI_COMMAND_LEN); | |
1155 | 1155 | if (ctx->command.data == NULL) { |
1156 | 1156 | return NGX_ERROR; |
1157 | 1157 | } |
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | ctx->param->key.len = 1; |
1220 | ctx->param->key.data = ngx_palloc(r->pool, | |
1221 | NGX_HTTP_SSI_PARAM_LEN); | |
1220 | ctx->param->key.data = ngx_pnalloc(r->pool, | |
1221 | NGX_HTTP_SSI_PARAM_LEN); | |
1222 | 1222 | if (ctx->param->key.data == NULL) { |
1223 | 1223 | return NGX_ERROR; |
1224 | 1224 | } |
1228 | 1228 | ctx->param->value.len = 0; |
1229 | 1229 | |
1230 | 1230 | if (ctx->value_buf == NULL) { |
1231 | ctx->param->value.data = ngx_palloc(r->pool, | |
1232 | ctx->value_len); | |
1231 | ctx->param->value.data = ngx_pnalloc(r->pool, | |
1232 | ctx->value_len); | |
1233 | 1233 | if (ctx->param->value.data == NULL) { |
1234 | 1234 | return NGX_ERROR; |
1235 | 1235 | } |
1407 | 1407 | case ssi_postparam_state: |
1408 | 1408 | |
1409 | 1409 | if (ctx->param->value.len + 1 < ctx->value_len / 2) { |
1410 | value = ngx_palloc(r->pool, ctx->param->value.len + 1); | |
1410 | value = ngx_pnalloc(r->pool, ctx->param->value.len + 1); | |
1411 | 1411 | if (value == NULL) { |
1412 | 1412 | return NGX_ERROR; |
1413 | 1413 | } |
1625 | 1625 | if (prefix) { |
1626 | 1626 | len = prefix + text->len; |
1627 | 1627 | |
1628 | data = ngx_palloc(r->pool, len); | |
1628 | data = ngx_pnalloc(r->pool, len); | |
1629 | 1629 | if (data == NULL) { |
1630 | 1630 | return NGX_ERROR; |
1631 | 1631 | } |
1828 | 1828 | } |
1829 | 1829 | } |
1830 | 1830 | |
1831 | p = ngx_palloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0)); | |
1831 | p = ngx_pnalloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0)); | |
1832 | 1832 | if (p == NULL) { |
1833 | 1833 | return NGX_ERROR; |
1834 | 1834 | } |
2221 | 2221 | NGX_ESCAPE_HTML); |
2222 | 2222 | |
2223 | 2223 | if (len) { |
2224 | p = ngx_palloc(r->pool, value->len + len); | |
2224 | p = ngx_pnalloc(r->pool, value->len + len); | |
2225 | 2225 | if (p == NULL) { |
2226 | 2226 | return NGX_HTTP_SSI_ERROR; |
2227 | 2227 | } |
2238 | 2238 | len = ngx_escape_html(NULL, value->data, value->len); |
2239 | 2239 | |
2240 | 2240 | if (len) { |
2241 | p = ngx_palloc(r->pool, value->len + len); | |
2241 | p = ngx_pnalloc(r->pool, value->len + len); | |
2242 | 2242 | if (p == NULL) { |
2243 | 2243 | return NGX_HTTP_SSI_ERROR; |
2244 | 2244 | } |
2285 | 2285 | |
2286 | 2286 | if (value) { |
2287 | 2287 | ctx->timefmt.len = value->len; |
2288 | ctx->timefmt.data = ngx_palloc(r->pool, value->len + 1); | |
2288 | ctx->timefmt.data = ngx_pnalloc(r->pool, value->len + 1); | |
2289 | 2289 | if (ctx->timefmt.data == NULL) { |
2290 | 2290 | return NGX_HTTP_SSI_ERROR; |
2291 | 2291 | } |
2665 | 2665 | || (ctx->timefmt.len == sizeof("%s") - 1 |
2666 | 2666 | && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's')) |
2667 | 2667 | { |
2668 | v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN); | |
2668 | v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN); | |
2669 | 2669 | if (v->data == NULL) { |
2670 | 2670 | return NGX_ERROR; |
2671 | 2671 | } |
2688 | 2688 | return NGX_ERROR; |
2689 | 2689 | } |
2690 | 2690 | |
2691 | v->data = ngx_palloc(r->pool, v->len); | |
2691 | v->data = ngx_pnalloc(r->pool, v->len); | |
2692 | 2692 | if (v->data == NULL) { |
2693 | 2693 | return NGX_ERROR; |
2694 | 2694 | } |
2737 | 2737 | |
2738 | 2738 | type->len = value[i].len; |
2739 | 2739 | |
2740 | type->data = ngx_palloc(cf->pool, type->len + 1); | |
2740 | type->data = ngx_pnalloc(cf->pool, type->len + 1); | |
2741 | 2741 | if (type->data == NULL) { |
2742 | 2742 | return NGX_CONF_ERROR; |
2743 | 2743 | } |
161 | 161 | len += r->args.len + 1; |
162 | 162 | } |
163 | 163 | |
164 | location = ngx_palloc(r->pool, len); | |
164 | location = ngx_pnalloc(r->pool, len); | |
165 | 165 | if (location == NULL) { |
166 | 166 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
167 | 167 | } |
709 | 709 | |
710 | 710 | type->len = value[i].len; |
711 | 711 | |
712 | type->data = ngx_palloc(cf->pool, type->len + 1); | |
712 | type->data = ngx_pnalloc(cf->pool, type->len + 1); | |
713 | 713 | if (type->data == NULL) { |
714 | 714 | return NGX_CONF_ERROR; |
715 | 715 | } |
419 | 419 | len += conf->domain.len; |
420 | 420 | } |
421 | 421 | |
422 | cookie = ngx_palloc(r->pool, len); | |
422 | cookie = ngx_pnalloc(r->pool, len); | |
423 | 423 | if (cookie == NULL) { |
424 | 424 | return NGX_ERROR; |
425 | 425 | } |
495 | 495 | ngx_str_t *name, uint32_t *uid) |
496 | 496 | { |
497 | 497 | v->len = name->len + sizeof("=00001111222233334444555566667777") - 1; |
498 | v->data = ngx_palloc(r->pool, v->len); | |
498 | v->data = ngx_pnalloc(r->pool, v->len); | |
499 | 499 | if (v->data == NULL) { |
500 | 500 | return NGX_ERROR; |
501 | 501 | } |
619 | 619 | return NGX_CONF_OK; |
620 | 620 | } |
621 | 621 | |
622 | new = ngx_palloc(cf->pool, sizeof("; domain=") - 1 + domain->len); | |
622 | new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len); | |
623 | 623 | if (new == NULL) { |
624 | 624 | return NGX_CONF_ERROR; |
625 | 625 | } |
641 | 641 | |
642 | 642 | u_char *p, *new; |
643 | 643 | |
644 | new = ngx_palloc(cf->pool, sizeof("; path=") - 1 + path->len); | |
644 | new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len); | |
645 | 645 | if (new == NULL) { |
646 | 646 | return NGX_CONF_ERROR; |
647 | 647 | } |
47 | 47 | return NGX_OK; |
48 | 48 | } |
49 | 49 | |
50 | s->data = ngx_palloc(r->pool, len); | |
50 | s->data = ngx_pnalloc(r->pool, len); | |
51 | 51 | if (s->data == NULL) { |
52 | 52 | return NGX_ERROR; |
53 | 53 | } |
241 | 241 | |
242 | 242 | /* look up hashed headers */ |
243 | 243 | |
244 | lowcase_key = ngx_palloc(r->pool, len); | |
244 | lowcase_key = ngx_pnalloc(r->pool, len); | |
245 | 245 | if (lowcase_key == NULL) { |
246 | 246 | XSRETURN_UNDEF; |
247 | 247 | } |
292 | 292 | size += ph[i]->value.len + sizeof("; ") - 1; |
293 | 293 | } |
294 | 294 | |
295 | cookie = ngx_palloc(r->pool, size); | |
295 | cookie = ngx_pnalloc(r->pool, size); | |
296 | 296 | if (cookie == NULL) { |
297 | 297 | XSRETURN_UNDEF; |
298 | 298 | } |
768 | 768 | |
769 | 769 | src = (u_char *) SvPV(text, len); |
770 | 770 | |
771 | p = ngx_palloc(r->pool, len + 1); | |
771 | p = ngx_pnalloc(r->pool, len + 1); | |
772 | 772 | if (p == NULL) { |
773 | 773 | XSRETURN_UNDEF; |
774 | 774 | } |
825 | 825 | |
826 | 826 | p = (u_char *) SvPV(name, len); |
827 | 827 | |
828 | lowcase = ngx_palloc(r->pool, len); | |
828 | lowcase = ngx_pnalloc(r->pool, len); | |
829 | 829 | if (lowcase == NULL) { |
830 | 830 | XSRETURN_UNDEF; |
831 | 831 | } |
702 | 702 | line = SvPVx(POPs, n_a); |
703 | 703 | rv->len = n_a; |
704 | 704 | |
705 | rv->data = ngx_palloc(r->pool, n_a); | |
705 | rv->data = ngx_pnalloc(r->pool, n_a); | |
706 | 706 | if (rv->data == NULL) { |
707 | 707 | return NGX_ERROR; |
708 | 708 | } |
1023 | 1023 | lq = (ngx_http_location_queue_t *) q; |
1024 | 1024 | len = lq->name->len - prefix; |
1025 | 1025 | |
1026 | node = ngx_palloc_aligned(cf->pool, | |
1027 | offsetof(ngx_http_location_tree_node_t, name) + len); | |
1026 | node = ngx_palloc(cf->pool, | |
1027 | offsetof(ngx_http_location_tree_node_t, name) + len); | |
1028 | 1028 | if (node == NULL) { |
1029 | 1029 | return NULL; |
1030 | 1030 | } |
1614 | 1614 | |
1615 | 1615 | hip->port = in_port->port; |
1616 | 1616 | |
1617 | hip->port_text.data = ngx_palloc(cf->pool, 7); | |
1617 | hip->port_text.data = ngx_pnalloc(cf->pool, 7); | |
1618 | 1618 | if (hip->port_text.data == NULL) { |
1619 | 1619 | return NGX_ERROR; |
1620 | 1620 | } |
831 | 831 | |
832 | 832 | } else { |
833 | 833 | len = clcf->name.len + 1 + r->args.len; |
834 | p = ngx_palloc(r->pool, len); | |
834 | p = ngx_pnalloc(r->pool, len); | |
835 | 835 | |
836 | 836 | if (p == NULL) { |
837 | 837 | ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1266 | 1266 | |
1267 | 1267 | if (c >= 'A' && c <= 'Z') { |
1268 | 1268 | |
1269 | p = ngx_palloc(r->pool, r->exten.len); | |
1269 | p = ngx_pnalloc(r->pool, r->exten.len); | |
1270 | 1270 | if (p == NULL) { |
1271 | 1271 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1272 | 1272 | } |
1389 | 1389 | |
1390 | 1390 | path->len = clcf->root.len + reserved; |
1391 | 1391 | |
1392 | path->data = ngx_palloc(r->pool, path->len); | |
1392 | path->data = ngx_pnalloc(r->pool, path->len); | |
1393 | 1393 | if (path->data == NULL) { |
1394 | 1394 | return NULL; |
1395 | 1395 | } |
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | auth.len = ngx_base64_decoded_length(encoded.len); |
1462 | auth.data = ngx_palloc(r->pool, auth.len + 1); | |
1462 | auth.data = ngx_pnalloc(r->pool, auth.len + 1); | |
1463 | 1463 | if (auth.data == NULL) { |
1464 | 1464 | return NGX_ERROR; |
1465 | 1465 | } |
653 | 653 | |
654 | 654 | if (r->complex_uri || r->quoted_uri) { |
655 | 655 | |
656 | r->uri.data = ngx_palloc(r->pool, r->uri.len + 1); | |
656 | r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1); | |
657 | 657 | if (r->uri.data == NULL) { |
658 | 658 | ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
659 | 659 | return; |
913 | 913 | h->value.data = r->header_start; |
914 | 914 | h->value.data[h->value.len] = '\0'; |
915 | 915 | |
916 | h->lowcase_key = ngx_palloc(r->pool, h->key.len); | |
916 | h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); | |
917 | 917 | if (h->lowcase_key == NULL) { |
918 | 918 | ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
919 | 919 | return; |
1561 | 1561 | server = buf; |
1562 | 1562 | |
1563 | 1563 | } else { |
1564 | server = ngx_palloc(r->pool, len); | |
1564 | server = ngx_pnalloc(r->pool, len); | |
1565 | 1565 | if (server == NULL) { |
1566 | 1566 | return NGX_ERROR; |
1567 | 1567 | } |
340 | 340 | |
341 | 341 | |
342 | 342 | value->len = len; |
343 | value->data = ngx_palloc(r->pool, len); | |
343 | value->data = ngx_pnalloc(r->pool, len); | |
344 | 344 | if (value->data == NULL) { |
345 | 345 | return NULL; |
346 | 346 | } |
732 | 732 | e->buf.len += r->args.len + 1; |
733 | 733 | } |
734 | 734 | |
735 | e->buf.data = ngx_palloc(r->pool, e->buf.len); | |
735 | e->buf.data = ngx_pnalloc(r->pool, e->buf.len); | |
736 | 736 | if (e->buf.data == NULL) { |
737 | 737 | e->ip = ngx_http_script_exit; |
738 | 738 | e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | e->buf.len = len; |
1122 | e->buf.data = ngx_palloc(e->request->pool, len); | |
1122 | e->buf.data = ngx_pnalloc(e->request->pool, len); | |
1123 | 1123 | if (e->buf.data == NULL) { |
1124 | 1124 | e->ip = ngx_http_script_exit; |
1125 | 1125 | e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
2816 | 2816 | } |
2817 | 2817 | } |
2818 | 2818 | |
2819 | p = ngx_palloc(r->pool, len); | |
2819 | p = ngx_pnalloc(r->pool, len); | |
2820 | 2820 | if (p == NULL) { |
2821 | 2821 | return NGX_ERROR; |
2822 | 2822 | } |
2877 | 2877 | |
2878 | 2878 | len = r->upstream_states->nelts * (3 + 2); |
2879 | 2879 | |
2880 | p = ngx_palloc(r->pool, len); | |
2880 | p = ngx_pnalloc(r->pool, len); | |
2881 | 2881 | if (p == NULL) { |
2882 | 2882 | return NGX_ERROR; |
2883 | 2883 | } |
2943 | 2943 | |
2944 | 2944 | len = r->upstream_states->nelts * (NGX_TIME_T_LEN + 4 + 2); |
2945 | 2945 | |
2946 | p = ngx_palloc(r->pool, len); | |
2946 | p = ngx_pnalloc(r->pool, len); | |
2947 | 2947 | if (p == NULL) { |
2948 | 2948 | return NGX_ERROR; |
2949 | 2949 | } |
282 | 282 | |
283 | 283 | len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1; |
284 | 284 | |
285 | p = ngx_palloc(r->pool, len); | |
285 | p = ngx_pnalloc(r->pool, len); | |
286 | 286 | if (p == NULL) { |
287 | 287 | return NGX_ERROR; |
288 | 288 | } |
271 | 271 | } |
272 | 272 | |
273 | 273 | v->name.len = name->len; |
274 | v->name.data = ngx_palloc(cf->pool, name->len); | |
274 | v->name.data = ngx_pnalloc(cf->pool, name->len); | |
275 | 275 | if (v->name.data == NULL) { |
276 | 276 | return NULL; |
277 | 277 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | v->name.len = name->len; |
341 | v->name.data = ngx_palloc(cf->pool, name->len); | |
341 | v->name.data = ngx_pnalloc(cf->pool, name->len); | |
342 | 342 | if (v->name.data == NULL) { |
343 | 343 | return NGX_ERROR; |
344 | 344 | } |
614 | 614 | len += h[i]->value.len + sizeof("; ") - 1; |
615 | 615 | } |
616 | 616 | |
617 | p = ngx_palloc(r->pool, len); | |
617 | p = ngx_pnalloc(r->pool, len); | |
618 | 618 | if (p == NULL) { |
619 | 619 | return NGX_ERROR; |
620 | 620 | } |
781 | 781 | v->no_cacheable = 0; |
782 | 782 | v->not_found = 0; |
783 | 783 | |
784 | v->data = ngx_palloc(r->pool, sizeof("65535") - 1); | |
784 | v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1); | |
785 | 785 | if (v->data == NULL) { |
786 | 786 | return NGX_ERROR; |
787 | 787 | } |
808 | 808 | { |
809 | 809 | ngx_str_t s; |
810 | 810 | |
811 | s.data = ngx_palloc(r->pool, INET_ADDRSTRLEN); | |
811 | s.data = ngx_pnalloc(r->pool, INET_ADDRSTRLEN); | |
812 | 812 | if (s.data == NULL) { |
813 | 813 | return NGX_ERROR; |
814 | 814 | } |
1031 | 1031 | sent = 0; |
1032 | 1032 | } |
1033 | 1033 | |
1034 | p = ngx_palloc(r->pool, NGX_OFF_T_LEN); | |
1034 | p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); | |
1035 | 1035 | if (p == NULL) { |
1036 | 1036 | return NGX_ERROR; |
1037 | 1037 | } |
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | if (r->headers_out.content_length_n >= 0) { |
1085 | p = ngx_palloc(r->pool, NGX_OFF_T_LEN); | |
1085 | p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); | |
1086 | 1086 | if (p == NULL) { |
1087 | 1087 | return NGX_ERROR; |
1088 | 1088 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | if (r->headers_out.last_modified_time >= 0) { |
1122 | p = ngx_palloc(r->pool, | |
1122 | p = ngx_pnalloc(r->pool, | |
1123 | 1123 | sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1); |
1124 | 1124 | if (p == NULL) { |
1125 | 1125 | return NGX_ERROR; |
1178 | 1178 | |
1179 | 1179 | if (clcf->keepalive_header) { |
1180 | 1180 | |
1181 | p = ngx_palloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN); | |
1181 | p = ngx_pnalloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN); | |
1182 | 1182 | if (p == NULL) { |
1183 | 1183 | return NGX_ERROR; |
1184 | 1184 | } |
356 | 356 | imip->addrs[i].addr = in_addr[i].addr; |
357 | 357 | imip->addrs[i].ctx = in_addr[i].ctx; |
358 | 358 | |
359 | text = ngx_palloc(cf->pool, | |
360 | INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); | |
359 | text = ngx_pnalloc(cf->pool, | |
360 | INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); | |
361 | 361 | if (text == NULL) { |
362 | 362 | return NGX_CONF_ERROR; |
363 | 363 | } |
592 | 592 | { |
593 | 593 | s->login.len = ctx->header_end - ctx->header_start; |
594 | 594 | |
595 | s->login.data = ngx_palloc(s->connection->pool, s->login.len); | |
595 | s->login.data = ngx_pnalloc(s->connection->pool, s->login.len); | |
596 | 596 | if (s->login.data == NULL) { |
597 | 597 | ngx_close_connection(ctx->peer.connection); |
598 | 598 | ngx_destroy_pool(ctx->pool); |
613 | 613 | { |
614 | 614 | s->passwd.len = ctx->header_end - ctx->header_start; |
615 | 615 | |
616 | s->passwd.data = ngx_palloc(s->connection->pool, s->passwd.len); | |
616 | s->passwd.data = ngx_pnalloc(s->connection->pool, | |
617 | s->passwd.len); | |
617 | 618 | if (s->passwd.data == NULL) { |
618 | 619 | ngx_close_connection(ctx->peer.connection); |
619 | 620 | ngx_destroy_pool(ctx->pool); |
650 | 651 | { |
651 | 652 | ctx->errcode.len = ctx->header_end - ctx->header_start; |
652 | 653 | |
653 | ctx->errcode.data = ngx_palloc(s->connection->pool, | |
654 | ctx->errcode.len); | |
654 | ctx->errcode.data = ngx_pnalloc(s->connection->pool, | |
655 | ctx->errcode.len); | |
655 | 656 | if (ctx->errcode.data == NULL) { |
656 | 657 | ngx_close_connection(ctx->peer.connection); |
657 | 658 | ngx_destroy_pool(ctx->pool); |
690 | 691 | ctx->err.len = ctx->errcode.len + ctx->errmsg.len |
691 | 692 | + sizeof(" " CRLF) - 1; |
692 | 693 | |
693 | p = ngx_palloc(s->connection->pool, ctx->err.len); | |
694 | p = ngx_pnalloc(s->connection->pool, ctx->err.len); | |
694 | 695 | if (p == NULL) { |
695 | 696 | ngx_close_connection(ctx->peer.connection); |
696 | 697 | ngx_destroy_pool(ctx->pool); |
809 | 810 | |
810 | 811 | peer->name.len = len; |
811 | 812 | |
812 | peer->name.data = ngx_palloc(s->connection->pool, len); | |
813 | peer->name.data = ngx_pnalloc(s->connection->pool, len); | |
813 | 814 | if (peer->name.data == NULL) { |
814 | 815 | ngx_destroy_pool(ctx->pool); |
815 | 816 | ngx_mail_session_internal_server_error(s); |
1254 | 1255 | |
1255 | 1256 | escaped->len = text->len + n * 2; |
1256 | 1257 | |
1257 | p = ngx_palloc(pool, escaped->len); | |
1258 | p = ngx_pnalloc(pool, escaped->len); | |
1258 | 1259 | if (p == NULL) { |
1259 | 1260 | return NGX_ERROR; |
1260 | 1261 | } |
1325 | 1326 | len += header[i].key.len + 2 + header[i].value.len + 2; |
1326 | 1327 | } |
1327 | 1328 | |
1328 | p = ngx_palloc(cf->pool, len); | |
1329 | p = ngx_pnalloc(cf->pool, len); | |
1329 | 1330 | if (p == NULL) { |
1330 | 1331 | return NGX_CONF_ERROR; |
1331 | 1332 | } |
235 | 235 | ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c, |
236 | 236 | ngx_mail_core_srv_conf_t *cscf) |
237 | 237 | { |
238 | s->salt.data = ngx_palloc(c->pool, | |
239 | sizeof(" <18446744073709551616.@>" CRLF) - 1 | |
240 | + NGX_TIME_T_LEN | |
241 | + cscf->server_name.len); | |
238 | s->salt.data = ngx_pnalloc(c->pool, | |
239 | sizeof(" <18446744073709551616.@>" CRLF) - 1 | |
240 | + NGX_TIME_T_LEN | |
241 | + cscf->server_name.len); | |
242 | 242 | if (s->salt.data == NULL) { |
243 | 243 | return NGX_ERROR; |
244 | 244 | } |
287 | 287 | "mail auth plain: \"%V\"", &arg[n]); |
288 | 288 | #endif |
289 | 289 | |
290 | plain.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[n].len)); | |
290 | plain.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[n].len)); | |
291 | 291 | if (plain.data == NULL){ |
292 | 292 | return NGX_ERROR; |
293 | 293 | } |
343 | 343 | ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
344 | 344 | "mail auth login username: \"%V\"", &arg[0]); |
345 | 345 | |
346 | s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | |
346 | s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | |
347 | 347 | if (s->login.data == NULL){ |
348 | 348 | return NGX_ERROR; |
349 | 349 | } |
373 | 373 | "mail auth login password: \"%V\"", &arg[0]); |
374 | 374 | #endif |
375 | 375 | |
376 | s->passwd.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | |
376 | s->passwd.data = ngx_pnalloc(c->pool, | |
377 | ngx_base64_decoded_length(arg[0].len)); | |
377 | 378 | if (s->passwd.data == NULL){ |
378 | 379 | return NGX_ERROR; |
379 | 380 | } |
401 | 402 | ngx_str_t salt; |
402 | 403 | ngx_uint_t n; |
403 | 404 | |
404 | p = ngx_palloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2); | |
405 | p = ngx_pnalloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2); | |
405 | 406 | if (p == NULL) { |
406 | 407 | return NGX_ERROR; |
407 | 408 | } |
433 | 434 | ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
434 | 435 | "mail auth cram-md5: \"%V\"", &arg[0]); |
435 | 436 | |
436 | s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | |
437 | s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | |
437 | 438 | if (s->login.data == NULL){ |
438 | 439 | return NGX_ERROR; |
439 | 440 | } |
258 | 258 | |
259 | 259 | if (s->tagged_line.len < s->tag.len + s->text.len + s->out.len) { |
260 | 260 | s->tagged_line.len = s->tag.len + s->text.len + s->out.len; |
261 | s->tagged_line.data = ngx_palloc(c->pool, s->tagged_line.len); | |
261 | s->tagged_line.data = ngx_pnalloc(c->pool, s->tagged_line.len); | |
262 | 262 | if (s->tagged_line.data == NULL) { |
263 | 263 | ngx_mail_close_connection(c); |
264 | 264 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | s->login.len = arg[0].len; |
319 | s->login.data = ngx_palloc(c->pool, s->login.len); | |
319 | s->login.data = ngx_pnalloc(c->pool, s->login.len); | |
320 | 320 | if (s->login.data == NULL) { |
321 | 321 | return NGX_ERROR; |
322 | 322 | } |
324 | 324 | ngx_memcpy(s->login.data, arg[0].data, s->login.len); |
325 | 325 | |
326 | 326 | s->passwd.len = arg[1].len; |
327 | s->passwd.data = ngx_palloc(c->pool, s->passwd.len); | |
327 | s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len); | |
328 | 328 | if (s->passwd.data == NULL) { |
329 | 329 | return NGX_ERROR; |
330 | 330 | } |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | p = ngx_palloc(cf->pool, size); | |
185 | p = ngx_pnalloc(cf->pool, size); | |
186 | 186 | if (p == NULL) { |
187 | 187 | return NGX_CONF_ERROR; |
188 | 188 | } |
215 | 215 | |
216 | 216 | size += sizeof(" STARTTLS") - 1; |
217 | 217 | |
218 | p = ngx_palloc(cf->pool, size); | |
218 | p = ngx_pnalloc(cf->pool, size); | |
219 | 219 | if (p == NULL) { |
220 | 220 | return NGX_CONF_ERROR; |
221 | 221 | } |
232 | 232 | size = (auth - conf->capability.data) + sizeof(CRLF) - 1 |
233 | 233 | + sizeof(" STARTTLS LOGINDISABLED") - 1; |
234 | 234 | |
235 | p = ngx_palloc(cf->pool, size); | |
235 | p = ngx_pnalloc(cf->pool, size); | |
236 | 236 | if (p == NULL) { |
237 | 237 | return NGX_CONF_ERROR; |
238 | 238 | } |
45 | 45 | return; |
46 | 46 | } |
47 | 47 | |
48 | s->out.data = ngx_palloc(c->pool, sizeof(pop3_greeting) + s->salt.len); | |
48 | s->out.data = ngx_pnalloc(c->pool, sizeof(pop3_greeting) + s->salt.len); | |
49 | 49 | if (s->out.data == NULL) { |
50 | 50 | ngx_mail_session_internal_server_error(s); |
51 | 51 | return; |
296 | 296 | |
297 | 297 | arg = s->args.elts; |
298 | 298 | s->login.len = arg[0].len; |
299 | s->login.data = ngx_palloc(c->pool, s->login.len); | |
299 | s->login.data = ngx_pnalloc(c->pool, s->login.len); | |
300 | 300 | if (s->login.data == NULL) { |
301 | 301 | return NGX_ERROR; |
302 | 302 | } |
323 | 323 | |
324 | 324 | arg = s->args.elts; |
325 | 325 | s->passwd.len = arg[0].len; |
326 | s->passwd.data = ngx_palloc(c->pool, s->passwd.len); | |
326 | s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len); | |
327 | 327 | if (s->passwd.data == NULL) { |
328 | 328 | return NGX_ERROR; |
329 | 329 | } |
416 | 416 | arg = s->args.elts; |
417 | 417 | |
418 | 418 | s->login.len = arg[0].len; |
419 | s->login.data = ngx_palloc(c->pool, s->login.len); | |
419 | s->login.data = ngx_pnalloc(c->pool, s->login.len); | |
420 | 420 | if (s->login.data == NULL) { |
421 | 421 | return NGX_ERROR; |
422 | 422 | } |
424 | 424 | ngx_memcpy(s->login.data, arg[0].data, s->login.len); |
425 | 425 | |
426 | 426 | s->passwd.len = arg[1].len; |
427 | s->passwd.data = ngx_palloc(c->pool, s->passwd.len); | |
427 | s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len); | |
428 | 428 | if (s->passwd.data == NULL) { |
429 | 429 | return NGX_ERROR; |
430 | 430 | } |
182 | 182 | size += sizeof("SASL LOGIN PLAIN" CRLF) - 1; |
183 | 183 | } |
184 | 184 | |
185 | p = ngx_palloc(cf->pool, size); | |
185 | p = ngx_pnalloc(cf->pool, size); | |
186 | 186 | if (p == NULL) { |
187 | 187 | return NGX_CONF_ERROR; |
188 | 188 | } |
212 | 212 | |
213 | 213 | size += sizeof("STLS" CRLF) - 1; |
214 | 214 | |
215 | p = ngx_palloc(cf->pool, size); | |
215 | p = ngx_pnalloc(cf->pool, size); | |
216 | 216 | if (p == NULL) { |
217 | 217 | return NGX_CONF_ERROR; |
218 | 218 | } |
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | p = ngx_palloc(cf->pool, stls_only_size); | |
238 | p = ngx_pnalloc(cf->pool, stls_only_size); | |
239 | 239 | if (p == NULL) { |
240 | 240 | return NGX_CONF_ERROR; |
241 | 241 | } |
252 | 252 | s->connection->log->action = "sending user name to upstream"; |
253 | 253 | |
254 | 254 | line.len = sizeof("USER ") - 1 + s->login.len + 2; |
255 | line.data = ngx_palloc(c->pool, line.len); | |
255 | line.data = ngx_pnalloc(c->pool, line.len); | |
256 | 256 | if (line.data == NULL) { |
257 | 257 | ngx_mail_proxy_internal_server_error(s); |
258 | 258 | return; |
271 | 271 | s->connection->log->action = "sending password to upstream"; |
272 | 272 | |
273 | 273 | line.len = sizeof("PASS ") - 1 + s->passwd.len + 2; |
274 | line.data = ngx_palloc(c->pool, line.len); | |
274 | line.data = ngx_pnalloc(c->pool, line.len); | |
275 | 275 | if (line.data == NULL) { |
276 | 276 | ngx_mail_proxy_internal_server_error(s); |
277 | 277 | return; |
368 | 368 | |
369 | 369 | line.len = s->tag.len + sizeof("LOGIN ") - 1 |
370 | 370 | + 1 + NGX_SIZE_T_LEN + 1 + 2; |
371 | line.data = ngx_palloc(c->pool, line.len); | |
371 | line.data = ngx_pnalloc(c->pool, line.len); | |
372 | 372 | if (line.data == NULL) { |
373 | 373 | ngx_mail_proxy_internal_server_error(s); |
374 | 374 | return; |
387 | 387 | s->connection->log->action = "sending user name to upstream"; |
388 | 388 | |
389 | 389 | line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2; |
390 | line.data = ngx_palloc(c->pool, line.len); | |
390 | line.data = ngx_pnalloc(c->pool, line.len); | |
391 | 391 | if (line.data == NULL) { |
392 | 392 | ngx_mail_proxy_internal_server_error(s); |
393 | 393 | return; |
407 | 407 | s->connection->log->action = "sending password to upstream"; |
408 | 408 | |
409 | 409 | line.len = s->passwd.len + 2; |
410 | line.data = ngx_palloc(c->pool, line.len); | |
410 | line.data = ngx_pnalloc(c->pool, line.len); | |
411 | 411 | if (line.data == NULL) { |
412 | 412 | ngx_mail_proxy_internal_server_error(s); |
413 | 413 | return; |
504 | 504 | cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
505 | 505 | |
506 | 506 | line.len = sizeof("HELO ") - 1 + cscf->server_name.len + 2; |
507 | line.data = ngx_palloc(c->pool, line.len); | |
507 | line.data = ngx_pnalloc(c->pool, line.len); | |
508 | 508 | if (line.data == NULL) { |
509 | 509 | ngx_mail_proxy_internal_server_error(s); |
510 | 510 | return; |
534 | 534 | + s->esmtp + s->smtp_helo.len |
535 | 535 | + s->connection->addr_text.len + s->login.len + s->host.len; |
536 | 536 | |
537 | line.data = ngx_palloc(c->pool, line.len); | |
537 | line.data = ngx_pnalloc(c->pool, line.len); | |
538 | 538 | if (line.data == NULL) { |
539 | 539 | ngx_mail_proxy_internal_server_error(s); |
540 | 540 | return; |
505 | 505 | |
506 | 506 | s->smtp_helo.len = arg[0].len; |
507 | 507 | |
508 | s->smtp_helo.data = ngx_palloc(c->pool, arg[0].len); | |
508 | s->smtp_helo.data = ngx_pnalloc(c->pool, arg[0].len); | |
509 | 509 | if (s->smtp_helo.data == NULL) { |
510 | 510 | return NGX_ERROR; |
511 | 511 | } |
159 | 159 | |
160 | 160 | size = sizeof("220 ESMTP ready" CRLF) - 1 + cscf->server_name.len; |
161 | 161 | |
162 | p = ngx_palloc(cf->pool, size); | |
162 | p = ngx_pnalloc(cf->pool, size); | |
163 | 163 | if (p == NULL) { |
164 | 164 | return NGX_CONF_ERROR; |
165 | 165 | } |
174 | 174 | |
175 | 175 | size = sizeof("250 " CRLF) - 1 + cscf->server_name.len; |
176 | 176 | |
177 | p = ngx_palloc(cf->pool, size); | |
177 | p = ngx_pnalloc(cf->pool, size); | |
178 | 178 | if (p == NULL) { |
179 | 179 | return NGX_CONF_ERROR; |
180 | 180 | } |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | p = ngx_palloc(cf->pool, size); | |
211 | p = ngx_pnalloc(cf->pool, size); | |
212 | 212 | if (p == NULL) { |
213 | 213 | return NGX_CONF_ERROR; |
214 | 214 | } |
246 | 246 | |
247 | 247 | size += sizeof("250 STARTTLS" CRLF) - 1; |
248 | 248 | |
249 | p = ngx_palloc(cf->pool, size); | |
249 | p = ngx_pnalloc(cf->pool, size); | |
250 | 250 | if (p == NULL) { |
251 | 251 | return NGX_CONF_ERROR; |
252 | 252 | } |
267 | 267 | size = (auth - conf->capability.data) |
268 | 268 | + sizeof("250 STARTTLS" CRLF) - 1; |
269 | 269 | |
270 | p = ngx_palloc(cf->pool, size); | |
270 | p = ngx_pnalloc(cf->pool, size); | |
271 | 271 | if (p == NULL) { |
272 | 272 | return NGX_CONF_ERROR; |
273 | 273 | } |
128 | 128 | |
129 | 129 | m->query.len = NGX_MYSQL_CMDPKT_LEN + ngx_mysql_command_query.len; |
130 | 130 | |
131 | m->query.data = ngx_palloc(r->pool, m->query.len); | |
131 | m->query.data = ngx_pnalloc(r->pool, m->query.len); | |
132 | 132 | if (m->query.data == NULL) { |
133 | 133 | ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
134 | 134 | return; |
214 | 214 | len += 20; |
215 | 215 | } |
216 | 216 | |
217 | auth = ngx_palloc(m->pool, len); | |
217 | auth = ngx_pnalloc(m->pool, len); | |
218 | 218 | if (auth == NULL) { |
219 | 219 | ngx_mysql_close(m, NGX_ERROR); |
220 | 220 | return; |
107 | 107 | size += ngx_strlen(ngx_argv[i]) + 1; |
108 | 108 | } |
109 | 109 | |
110 | title = ngx_palloc(cycle->pool, size); | |
110 | title = ngx_pnalloc(cycle->pool, size); | |
111 | 111 | |
112 | 112 | p = ngx_cpymem(title, master_process, sizeof(master_process) - 1); |
113 | 113 | for (i = 0; i < ngx_argc; i++) { |
42 | 42 | if (err == 0) { |
43 | 43 | len = ngx_strlen(value); |
44 | 44 | |
45 | *encrypted = ngx_palloc(pool, len); | |
45 | *encrypted = ngx_pnalloc(pool, len); | |
46 | 46 | if (*encrypted) { |
47 | 47 | ngx_memcpy(*encrypted, value, len + 1); |
48 | 48 | return NGX_OK; |
80 | 80 | if (value) { |
81 | 81 | len = ngx_strlen(value); |
82 | 82 | |
83 | *encrypted = ngx_palloc(pool, len); | |
83 | *encrypted = ngx_pnalloc(pool, len); | |
84 | 84 | if (*encrypted) { |
85 | 85 | ngx_memcpy(*encrypted, value, len + 1); |
86 | 86 | } |