Klaus Demo nginx / 7f6b2ff
*) back out r2040 *) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header Igor Sysoev 14 years ago
54 changed file(s) with 287 addition(s) and 249 deletion(s). Raw diff Collapse all Expand all
825825
826826 ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT);
827827
828 ccf->oldpid.data = ngx_palloc(cycle->pool, ccf->oldpid.len);
828 ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len);
829829 if (ccf->oldpid.data == NULL) {
830830 return NGX_CONF_ERROR;
831831 }
869869
870870 } else {
871871 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,
873873 ccf->lock_file.len + sizeof(".accept"));
874874 if (cycle->lock_file.data == NULL) {
875875 return NGX_CONF_ERROR;
3838
3939 p = a->pool;
4040
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;
4343 }
4444
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;
4747 }
4848 }
4949
6363
6464 p = a->pool;
6565
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)
6768 {
6869 /*
6970 * the array allocation is the last in the pool
7071 * and there is space for new allocation
7172 */
7273
73 p->last += a->size;
74 p->d.last += a->size;
7475 a->nalloc++;
7576
7677 } else {
110111
111112 p = a->pool;
112113
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)
115116 {
116117 /*
117118 * the array allocation is the last in the pool
118119 * and there is space for new allocation
119120 */
120121
121 p->last += size;
122 p->d.last += size;
122123 a->nalloc += n;
123124
124125 } else {
573573 return NGX_ERROR;
574574 }
575575
576 word->data = ngx_palloc(cf->pool, b->pos - start + 1);
576 word->data = ngx_pnalloc(cf->pool, b->pos - start + 1);
577577 if (word->data == NULL) {
578578 return NGX_ERROR;
579579 }
725725 }
726726
727727 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);
729729 if (name->data == NULL) {
730730 return NGX_ERROR;
731731 }
3535 sin->sin_port = htons(port);
3636
3737
38 ls->addr_text.data = ngx_palloc(cf->pool,
38 ls->addr_text.data = ngx_pnalloc(cf->pool,
3939 INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1);
4040 if (ls->addr_text.data == NULL) {
4141 return NULL;
105105
106106 ls[i].addr_text_max_len = INET_ADDRSTRLEN;
107107
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);
110110 if (ls[i].addr_text.data == NULL) {
111111 return NGX_ERROR;
112112 }
8080
8181
8282 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);
8484 if (cycle->conf_file.data == NULL) {
8585 ngx_destroy_pool(pool);
8686 return NULL;
181181 hostname[NGX_MAXHOSTNAMELEN - 1] = '\0';
182182 cycle->hostname.len = ngx_strlen(hostname);
183183
184 cycle->hostname.data = ngx_palloc(pool, cycle->hostname.len);
184 cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len);
185185 if (cycle->hostname.data == NULL) {
186186 ngx_destroy_pool(pool);
187187 return NULL;
459459
460460 #else
461461
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);
464464
465465 if (lock_file == NULL) {
466466 goto failed;
4545
4646 file->name.len = path->name.len + 1 + path->len + 10;
4747
48 file->name.data = ngx_palloc(pool, file->name.len + 1);
48 file->name.data = ngx_pnalloc(pool, file->name.len + 1);
4949 if (file->name.data == NULL) {
5050 return NGX_ERROR;
5151 }
838838 }
839839
840840 name->len = last - 1;
841 name->data = ngx_palloc(ha->temp_pool, name->len);
841 name->data = ngx_pnalloc(ha->temp_pool, name->len);
842842 if (name->data == NULL) {
843843 return NGX_ERROR;
844844 }
854854 * and ".example.com" to "com.example\0"
855855 */
856856
857 p = ngx_palloc(ha->temp_pool, last);
857 p = ngx_pnalloc(ha->temp_pool, last);
858858 if (p == NULL) {
859859 return NGX_ERROR;
860860 }
890890
891891 last++;
892892
893 p = ngx_palloc(ha->temp_pool, last);
893 p = ngx_pnalloc(ha->temp_pool, last);
894894 if (p == NULL) {
895895 return NGX_ERROR;
896896 }
943943 }
944944
945945 name->len = last - skip;
946 name->data = ngx_palloc(ha->temp_pool, name->len);
946 name->data = ngx_pnalloc(ha->temp_pool, name->len);
947947 if (name->data == NULL) {
948948 return NGX_ERROR;
949949 }
577577
578578 len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
579579
580 p = ngx_palloc(pool, len);
580 p = ngx_pnalloc(pool, len);
581581 if (p == NULL) {
582582 return NGX_ERROR;
583583 }
613613 u->addrs[0].sockaddr = (struct sockaddr *) sin;
614614 u->addrs[0].socklen = sizeof(struct sockaddr_in);
615615
616 p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1);
616 p = ngx_pnalloc(pool, u->host.len + sizeof(":65536") - 1);
617617 if (p == NULL) {
618618 return NGX_ERROR;
619619 }
77 #include <ngx_core.h>
88
99
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
1014 ngx_pool_t *
1115 ngx_create_pool(size_t size, ngx_log_t *log)
1216 {
1721 return NULL;
1822 }
1923
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;
2230 p->current = p;
2331 p->chain = NULL;
24 p->next = NULL;
2532 p->large = NULL;
2633 p->cleanup = NULL;
2734 p->log = log;
6168 * so we can not use this log while the free()ing the pool
6269 */
6370
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) {
6572 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);
6774
6875 if (n == NULL) {
6976 break;
7279
7380 #endif
7481
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) {
7683 ngx_free(p);
7784
7885 if (n == NULL) {
8592 void *
8693 ngx_palloc(ngx_pool_t *pool, size_t size)
8794 {
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
96100 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;
116107
117108 return m;
118109 }
119110
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;
122139 }
123140
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;
147187
148188 #if 0
149189 p = ngx_memalign(ngx_pagesize, size, pool->log);
168208 pool->large = large;
169209
170210 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);
182211 }
183212
184213
4242 };
4343
4444
45 struct ngx_pool_s {
45 typedef struct {
4646 u_char *last;
4747 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;
4855 ngx_pool_t *current;
4956 ngx_chain_t *chain;
50 ngx_pool_t *next;
5157 ngx_pool_large_t *large;
5258 ngx_pool_cleanup_t *cleanup;
5359 ngx_log_t *log;
6874 void ngx_destroy_pool(ngx_pool_t *pool);
6975
7076 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);
7278 void *ngx_pcalloc(ngx_pool_t *pool, size_t size);
7379 ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p);
7480
164164 #endif
165165
166166 if (pool) {
167 return ngx_palloc_aligned(pool, size);
167 return ngx_palloc(pool, size);
168168 }
169169
170170 return NULL;
3333 {
3434 u_char *dst;
3535
36 dst = ngx_palloc(pool, src->len);
36 dst = ngx_pnalloc(pool, src->len);
3737 if (dst == NULL) {
3838 return NULL;
3939 }
200200 #endif
201201
202202 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);
204204 if (c->addr_text.data == NULL) {
205205 ngx_close_accepted_connection(c);
206206 return;
5757 }
5858
5959 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);
6262 if (c->addr_text.data == NULL) {
6363 /* TODO: close socket */
6464 return;
19061906 len = BIO_pending(bio);
19071907 s->len = len;
19081908
1909 s->data = ngx_palloc(pool, len);
1909 s->data = ngx_pnalloc(pool, len);
19101910 if (s->data == NULL) {
19111911 goto failed;
19121912 }
19531953 for (len = 0; p[len]; len++) { /* void */ }
19541954
19551955 s->len = len;
1956 s->data = ngx_palloc(pool, len);
1956 s->data = ngx_pnalloc(pool, len);
19571957 if (s->data == NULL) {
19581958 OPENSSL_free(p);
19591959 X509_free(cert);
19951995 for (len = 0; p[len]; len++) { /* void */ }
19961996
19971997 s->len = len;
1998 s->data = ngx_palloc(pool, len);
1998 s->data = ngx_pnalloc(pool, len);
19991999 if (s->data == NULL) {
20002000 OPENSSL_free(p);
20012001 X509_free(cert);
20352035 len = BIO_pending(bio);
20362036
20372037 s->len = len;
2038 s->data = ngx_palloc(pool, len);
2038 s->data = ngx_pnalloc(pool, len);
20392039 if (s->data == NULL) {
20402040 BIO_free(bio);
20412041 X509_free(cert);
231231
232232 if (state == sw_passwd) {
233233 pwd.len = i - passwd;
234 pwd.data = ngx_palloc(r->pool, pwd.len + 1);
234 pwd.data = ngx_pnalloc(r->pool, pwd.len + 1);
235235 if (pwd.data == NULL) {
236236 return NGX_HTTP_INTERNAL_SERVER_ERROR;
237237 }
399399
400400 len = sizeof("Basic realm=\"") - 1 + realm->len + 1;
401401
402 basic = ngx_palloc(cf->pool, len);
402 basic = ngx_pnalloc(cf->pool, len);
403403 if (basic == NULL) {
404404 return NGX_CONF_ERROR;
405405 }
281281 allocated = path.len + 1 + len + 1
282282 + NGX_HTTP_AUTOINDEX_PREALLOCATE;
283283
284 filename = ngx_palloc(pool, allocated);
284 filename = ngx_pnalloc(pool, allocated);
285285 if (filename == NULL) {
286286 return ngx_http_autoindex_error(r, &dir, &path);
287287 }
317317
318318 entry->name.len = len;
319319
320 entry->name.data = ngx_palloc(pool, len + 1);
320 entry->name.data = ngx_pnalloc(pool, len + 1);
321321 if (entry->name.data == NULL) {
322322 return ngx_http_autoindex_error(r, &dir, &path);
323323 }
11011101 location = path + clcf->root.len;
11021102
11031103 } else {
1104 location = ngx_palloc(r->pool, r->uri.len);
1104 location = ngx_pnalloc(r->pool, r->uri.len);
11051105 if (location == NULL) {
11061106 return NGX_ERROR;
11071107 }
10581058 size += part[i].end - part[i].start;
10591059 }
10601060
1061 p = ngx_palloc(r->pool, size);
1061 p = ngx_pnalloc(r->pool, size);
10621062 if (p == NULL) {
10631063 return NGX_ERROR;
10641064 }
10861086 h->value.data = r->header_start;
10871087 h->value.data[h->value.len] = '\0';
10881088
1089 h->lowcase_key = ngx_palloc(r->pool, h->key.len);
1089 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
10901090 if (h->lowcase_key == NULL) {
10911091 return NGX_ERROR;
10921092 }
10961096 h->key.len = r->header_name_end - r->header_name_start;
10971097 h->value.len = r->header_end - r->header_start;
10981098
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);
11021102 if (h->key.data == NULL) {
11031103 return NGX_ERROR;
11041104 }
20142014
20152015 v->len = r->uri.len + flcf->index.len;
20162016
2017 v->data = ngx_palloc(r->pool, v->len);
2017 v->data = ngx_pnalloc(r->pool, v->len);
20182018 if (v->data == NULL) {
20192019 return NGX_ERROR;
20202020 }
801801 return NGX_OK;
802802 }
803803
804 v->data = ngx_palloc(r->pool, NGX_INT32_LEN + 3);
804 v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3);
805805 if (v->data == NULL) {
806806 return NGX_ERROR;
807807 }
950950
951951 type->len = value[i].len;
952952
953 type->data = ngx_palloc(cf->pool, type->len + 1);
953 type->data = ngx_pnalloc(cf->pool, type->len + 1);
954954 if (type->data == NULL) {
955955 return NGX_CONF_ERROR;
956956 }
263263 return NGX_OK;
264264 }
265265
266 expires->value.data = ngx_palloc(r->pool, len);
266 expires->value.data = ngx_pnalloc(r->pool, len);
267267 if (expires->value.data == NULL) {
268268 return NGX_ERROR;
269269 }
296296 return NGX_OK;
297297 }
298298
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);
301301 if (cc->value.data == NULL) {
302302 return NGX_ERROR;
303303 }
253253 uri.data = path.data + root;
254254
255255 } else {
256 uri.data = ngx_palloc(r->pool, uri.len);
256 uri.data = ngx_pnalloc(r->pool, uri.len);
257257 if (uri.data == NULL) {
258258 return NGX_HTTP_INTERNAL_SERVER_ERROR;
259259 }
260260 }
261261 }
262262
263 line = ngx_palloc(r->pool, len);
263 line = ngx_pnalloc(r->pool, len);
264264 if (line == NULL) {
265265 return NGX_ERROR;
266266 }
969969 } else {
970970 op->run = ngx_http_log_copy_long;
971971
972 p = ngx_palloc(cf->pool, len);
972 p = ngx_pnalloc(cf->pool, len);
973973 if (p == NULL) {
974974 return NGX_CONF_ERROR;
975975 }
129129 return NGX_OK;
130130 }
131131
132 name = ngx_palloc(r->pool, len);
132 name = ngx_pnalloc(r->pool, len);
133133 if (name == NULL) {
134134 return NGX_ERROR;
135135 }
963963 u->state->status = ctx->status;
964964
965965 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);
968968 if (u->headers_in.status_line.data == NULL) {
969969 return NGX_ERROR;
970970 }
12191219 h->key.len = r->header_name_end - r->header_name_start;
12201220 h->value.len = r->header_end - r->header_start;
12211221
1222 h->key.data = ngx_palloc(r->pool,
1222 h->key.data = ngx_pnalloc(r->pool,
12231223 h->key.len + 1 + h->value.len + 1 + h->key.len);
12241224 if (h->key.data == NULL) {
12251225 return NGX_ERROR;
13991399 v->len = r->headers_in.x_forwarded_for->value.len
14001400 + sizeof(", ") - 1 + r->connection->addr_text.len;
14011401
1402 p = ngx_palloc(r->pool, v->len);
1402 p = ngx_pnalloc(r->pool, v->len);
14031403 if (p == NULL) {
14041404 return NGX_ERROR;
14051405 }
14341434 v->no_cacheable = 0;
14351435 v->not_found = 0;
14361436
1437 v->data = ngx_palloc(r->connection->pool, NGX_SIZE_T_LEN);
1437 v->data = ngx_pnalloc(r->connection->pool, NGX_SIZE_T_LEN);
14381438
14391439 if (v->data == NULL) {
14401440 return NGX_ERROR;
14911491
14921492 len = prefix + pr->replacement.text.len + h->value.len - pr->redirect.len;
14931493
1494 data = ngx_palloc(r->pool, len);
1494 data = ngx_pnalloc(r->pool, len);
14951495 if (data == NULL) {
14961496 return NGX_ERROR;
14971497 }
15431543 len += lcode(&e);
15441544 }
15451545
1546 data = ngx_palloc(r->pool, len);
1546 data = ngx_pnalloc(r->pool, len);
15471547 if (data == NULL) {
15481548 return NGX_ERROR;
15491549 }
306306 content_range->key.len = sizeof("Content-Range") - 1;
307307 content_range->key.data = (u_char *) "Content-Range";
308308
309 content_range->value.data = ngx_palloc(r->pool,
309 content_range->value.data = ngx_pnalloc(r->pool,
310310 sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
311311 if (content_range->value.data == NULL) {
312312 return NGX_ERROR;
340340 content_range->key.data = (u_char *) "Content-Range";
341341
342342 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);
344344 if (content_range->value.data == NULL) {
345345 return NGX_ERROR;
346346 }
375375 len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
376376 }
377377
378 ctx->boundary_header.data = ngx_palloc(r->pool, len);
378 ctx->boundary_header.data = ngx_pnalloc(r->pool, len);
379379 if (ctx->boundary_header.data == NULL) {
380380 return NGX_ERROR;
381381 }
413413 }
414414
415415 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);
419419
420420 if (r->headers_out.content_type.data == NULL) {
421421 return NGX_ERROR;
440440 /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */
441441
442442 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);
444444
445445 if (range[i].content_range.data == NULL) {
446446 return NGX_ERROR;
648648 b->temporary = 1;
649649 b->last_buf = 1;
650650
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);
653653 if (b->pos == NULL) {
654654 return NGX_ERROR;
655655 }
162162 return NGX_DECLINED;
163163 }
164164
165 p = ngx_palloc(r->connection->pool, len);
165 p = ngx_pnalloc(r->connection->pool, len);
166166 if (p == NULL) {
167167 return NGX_HTTP_INTERNAL_SERVER_ERROR;
168168 }
11501150
11511151 default:
11521152 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);
11551155 if (ctx->command.data == NULL) {
11561156 return NGX_ERROR;
11571157 }
12171217 }
12181218
12191219 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);
12221222 if (ctx->param->key.data == NULL) {
12231223 return NGX_ERROR;
12241224 }
12281228 ctx->param->value.len = 0;
12291229
12301230 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);
12331233 if (ctx->param->value.data == NULL) {
12341234 return NGX_ERROR;
12351235 }
14071407 case ssi_postparam_state:
14081408
14091409 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);
14111411 if (value == NULL) {
14121412 return NGX_ERROR;
14131413 }
16251625 if (prefix) {
16261626 len = prefix + text->len;
16271627
1628 data = ngx_palloc(r->pool, len);
1628 data = ngx_pnalloc(r->pool, len);
16291629 if (data == NULL) {
16301630 return NGX_ERROR;
16311631 }
18281828 }
18291829 }
18301830
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));
18321832 if (p == NULL) {
18331833 return NGX_ERROR;
18341834 }
22212221 NGX_ESCAPE_HTML);
22222222
22232223 if (len) {
2224 p = ngx_palloc(r->pool, value->len + len);
2224 p = ngx_pnalloc(r->pool, value->len + len);
22252225 if (p == NULL) {
22262226 return NGX_HTTP_SSI_ERROR;
22272227 }
22382238 len = ngx_escape_html(NULL, value->data, value->len);
22392239
22402240 if (len) {
2241 p = ngx_palloc(r->pool, value->len + len);
2241 p = ngx_pnalloc(r->pool, value->len + len);
22422242 if (p == NULL) {
22432243 return NGX_HTTP_SSI_ERROR;
22442244 }
22852285
22862286 if (value) {
22872287 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);
22892289 if (ctx->timefmt.data == NULL) {
22902290 return NGX_HTTP_SSI_ERROR;
22912291 }
26652665 || (ctx->timefmt.len == sizeof("%s") - 1
26662666 && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's'))
26672667 {
2668 v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN);
2668 v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN);
26692669 if (v->data == NULL) {
26702670 return NGX_ERROR;
26712671 }
26882688 return NGX_ERROR;
26892689 }
26902690
2691 v->data = ngx_palloc(r->pool, v->len);
2691 v->data = ngx_pnalloc(r->pool, v->len);
26922692 if (v->data == NULL) {
26932693 return NGX_ERROR;
26942694 }
27372737
27382738 type->len = value[i].len;
27392739
2740 type->data = ngx_palloc(cf->pool, type->len + 1);
2740 type->data = ngx_pnalloc(cf->pool, type->len + 1);
27412741 if (type->data == NULL) {
27422742 return NGX_CONF_ERROR;
27432743 }
161161 len += r->args.len + 1;
162162 }
163163
164 location = ngx_palloc(r->pool, len);
164 location = ngx_pnalloc(r->pool, len);
165165 if (location == NULL) {
166166 return NGX_HTTP_INTERNAL_SERVER_ERROR;
167167 }
709709
710710 type->len = value[i].len;
711711
712 type->data = ngx_palloc(cf->pool, type->len + 1);
712 type->data = ngx_pnalloc(cf->pool, type->len + 1);
713713 if (type->data == NULL) {
714714 return NGX_CONF_ERROR;
715715 }
419419 len += conf->domain.len;
420420 }
421421
422 cookie = ngx_palloc(r->pool, len);
422 cookie = ngx_pnalloc(r->pool, len);
423423 if (cookie == NULL) {
424424 return NGX_ERROR;
425425 }
495495 ngx_str_t *name, uint32_t *uid)
496496 {
497497 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);
499499 if (v->data == NULL) {
500500 return NGX_ERROR;
501501 }
619619 return NGX_CONF_OK;
620620 }
621621
622 new = ngx_palloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
622 new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
623623 if (new == NULL) {
624624 return NGX_CONF_ERROR;
625625 }
641641
642642 u_char *p, *new;
643643
644 new = ngx_palloc(cf->pool, sizeof("; path=") - 1 + path->len);
644 new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len);
645645 if (new == NULL) {
646646 return NGX_CONF_ERROR;
647647 }
4747 return NGX_OK;
4848 }
4949
50 s->data = ngx_palloc(r->pool, len);
50 s->data = ngx_pnalloc(r->pool, len);
5151 if (s->data == NULL) {
5252 return NGX_ERROR;
5353 }
241241
242242 /* look up hashed headers */
243243
244 lowcase_key = ngx_palloc(r->pool, len);
244 lowcase_key = ngx_pnalloc(r->pool, len);
245245 if (lowcase_key == NULL) {
246246 XSRETURN_UNDEF;
247247 }
292292 size += ph[i]->value.len + sizeof("; ") - 1;
293293 }
294294
295 cookie = ngx_palloc(r->pool, size);
295 cookie = ngx_pnalloc(r->pool, size);
296296 if (cookie == NULL) {
297297 XSRETURN_UNDEF;
298298 }
768768
769769 src = (u_char *) SvPV(text, len);
770770
771 p = ngx_palloc(r->pool, len + 1);
771 p = ngx_pnalloc(r->pool, len + 1);
772772 if (p == NULL) {
773773 XSRETURN_UNDEF;
774774 }
825825
826826 p = (u_char *) SvPV(name, len);
827827
828 lowcase = ngx_palloc(r->pool, len);
828 lowcase = ngx_pnalloc(r->pool, len);
829829 if (lowcase == NULL) {
830830 XSRETURN_UNDEF;
831831 }
702702 line = SvPVx(POPs, n_a);
703703 rv->len = n_a;
704704
705 rv->data = ngx_palloc(r->pool, n_a);
705 rv->data = ngx_pnalloc(r->pool, n_a);
706706 if (rv->data == NULL) {
707707 return NGX_ERROR;
708708 }
10231023 lq = (ngx_http_location_queue_t *) q;
10241024 len = lq->name->len - prefix;
10251025
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);
10281028 if (node == NULL) {
10291029 return NULL;
10301030 }
16141614
16151615 hip->port = in_port->port;
16161616
1617 hip->port_text.data = ngx_palloc(cf->pool, 7);
1617 hip->port_text.data = ngx_pnalloc(cf->pool, 7);
16181618 if (hip->port_text.data == NULL) {
16191619 return NGX_ERROR;
16201620 }
831831
832832 } else {
833833 len = clcf->name.len + 1 + r->args.len;
834 p = ngx_palloc(r->pool, len);
834 p = ngx_pnalloc(r->pool, len);
835835
836836 if (p == NULL) {
837837 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
12661266
12671267 if (c >= 'A' && c <= 'Z') {
12681268
1269 p = ngx_palloc(r->pool, r->exten.len);
1269 p = ngx_pnalloc(r->pool, r->exten.len);
12701270 if (p == NULL) {
12711271 return NGX_HTTP_INTERNAL_SERVER_ERROR;
12721272 }
13891389
13901390 path->len = clcf->root.len + reserved;
13911391
1392 path->data = ngx_palloc(r->pool, path->len);
1392 path->data = ngx_pnalloc(r->pool, path->len);
13931393 if (path->data == NULL) {
13941394 return NULL;
13951395 }
14591459 }
14601460
14611461 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);
14631463 if (auth.data == NULL) {
14641464 return NGX_ERROR;
14651465 }
653653
654654 if (r->complex_uri || r->quoted_uri) {
655655
656 r->uri.data = ngx_palloc(r->pool, r->uri.len + 1);
656 r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1);
657657 if (r->uri.data == NULL) {
658658 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
659659 return;
913913 h->value.data = r->header_start;
914914 h->value.data[h->value.len] = '\0';
915915
916 h->lowcase_key = ngx_palloc(r->pool, h->key.len);
916 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
917917 if (h->lowcase_key == NULL) {
918918 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
919919 return;
15611561 server = buf;
15621562
15631563 } else {
1564 server = ngx_palloc(r->pool, len);
1564 server = ngx_pnalloc(r->pool, len);
15651565 if (server == NULL) {
15661566 return NGX_ERROR;
15671567 }
340340
341341
342342 value->len = len;
343 value->data = ngx_palloc(r->pool, len);
343 value->data = ngx_pnalloc(r->pool, len);
344344 if (value->data == NULL) {
345345 return NULL;
346346 }
732732 e->buf.len += r->args.len + 1;
733733 }
734734
735 e->buf.data = ngx_palloc(r->pool, e->buf.len);
735 e->buf.data = ngx_pnalloc(r->pool, e->buf.len);
736736 if (e->buf.data == NULL) {
737737 e->ip = ngx_http_script_exit;
738738 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
11191119 }
11201120
11211121 e->buf.len = len;
1122 e->buf.data = ngx_palloc(e->request->pool, len);
1122 e->buf.data = ngx_pnalloc(e->request->pool, len);
11231123 if (e->buf.data == NULL) {
11241124 e->ip = ngx_http_script_exit;
11251125 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
28162816 }
28172817 }
28182818
2819 p = ngx_palloc(r->pool, len);
2819 p = ngx_pnalloc(r->pool, len);
28202820 if (p == NULL) {
28212821 return NGX_ERROR;
28222822 }
28772877
28782878 len = r->upstream_states->nelts * (3 + 2);
28792879
2880 p = ngx_palloc(r->pool, len);
2880 p = ngx_pnalloc(r->pool, len);
28812881 if (p == NULL) {
28822882 return NGX_ERROR;
28832883 }
29432943
29442944 len = r->upstream_states->nelts * (NGX_TIME_T_LEN + 4 + 2);
29452945
2946 p = ngx_palloc(r->pool, len);
2946 p = ngx_pnalloc(r->pool, len);
29472947 if (p == NULL) {
29482948 return NGX_ERROR;
29492949 }
282282
283283 len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
284284
285 p = ngx_palloc(r->pool, len);
285 p = ngx_pnalloc(r->pool, len);
286286 if (p == NULL) {
287287 return NGX_ERROR;
288288 }
271271 }
272272
273273 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);
275275 if (v->name.data == NULL) {
276276 return NULL;
277277 }
338338 }
339339
340340 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);
342342 if (v->name.data == NULL) {
343343 return NGX_ERROR;
344344 }
614614 len += h[i]->value.len + sizeof("; ") - 1;
615615 }
616616
617 p = ngx_palloc(r->pool, len);
617 p = ngx_pnalloc(r->pool, len);
618618 if (p == NULL) {
619619 return NGX_ERROR;
620620 }
781781 v->no_cacheable = 0;
782782 v->not_found = 0;
783783
784 v->data = ngx_palloc(r->pool, sizeof("65535") - 1);
784 v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1);
785785 if (v->data == NULL) {
786786 return NGX_ERROR;
787787 }
808808 {
809809 ngx_str_t s;
810810
811 s.data = ngx_palloc(r->pool, INET_ADDRSTRLEN);
811 s.data = ngx_pnalloc(r->pool, INET_ADDRSTRLEN);
812812 if (s.data == NULL) {
813813 return NGX_ERROR;
814814 }
10311031 sent = 0;
10321032 }
10331033
1034 p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
1034 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
10351035 if (p == NULL) {
10361036 return NGX_ERROR;
10371037 }
10821082 }
10831083
10841084 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);
10861086 if (p == NULL) {
10871087 return NGX_ERROR;
10881088 }
11191119 }
11201120
11211121 if (r->headers_out.last_modified_time >= 0) {
1122 p = ngx_palloc(r->pool,
1122 p = ngx_pnalloc(r->pool,
11231123 sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1);
11241124 if (p == NULL) {
11251125 return NGX_ERROR;
11781178
11791179 if (clcf->keepalive_header) {
11801180
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);
11821182 if (p == NULL) {
11831183 return NGX_ERROR;
11841184 }
356356 imip->addrs[i].addr = in_addr[i].addr;
357357 imip->addrs[i].ctx = in_addr[i].ctx;
358358
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);
361361 if (text == NULL) {
362362 return NGX_CONF_ERROR;
363363 }
592592 {
593593 s->login.len = ctx->header_end - ctx->header_start;
594594
595 s->login.data = ngx_palloc(s->connection->pool, s->login.len);
595 s->login.data = ngx_pnalloc(s->connection->pool, s->login.len);
596596 if (s->login.data == NULL) {
597597 ngx_close_connection(ctx->peer.connection);
598598 ngx_destroy_pool(ctx->pool);
613613 {
614614 s->passwd.len = ctx->header_end - ctx->header_start;
615615
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);
617618 if (s->passwd.data == NULL) {
618619 ngx_close_connection(ctx->peer.connection);
619620 ngx_destroy_pool(ctx->pool);
650651 {
651652 ctx->errcode.len = ctx->header_end - ctx->header_start;
652653
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);
655656 if (ctx->errcode.data == NULL) {
656657 ngx_close_connection(ctx->peer.connection);
657658 ngx_destroy_pool(ctx->pool);
690691 ctx->err.len = ctx->errcode.len + ctx->errmsg.len
691692 + sizeof(" " CRLF) - 1;
692693
693 p = ngx_palloc(s->connection->pool, ctx->err.len);
694 p = ngx_pnalloc(s->connection->pool, ctx->err.len);
694695 if (p == NULL) {
695696 ngx_close_connection(ctx->peer.connection);
696697 ngx_destroy_pool(ctx->pool);
809810
810811 peer->name.len = len;
811812
812 peer->name.data = ngx_palloc(s->connection->pool, len);
813 peer->name.data = ngx_pnalloc(s->connection->pool, len);
813814 if (peer->name.data == NULL) {
814815 ngx_destroy_pool(ctx->pool);
815816 ngx_mail_session_internal_server_error(s);
12541255
12551256 escaped->len = text->len + n * 2;
12561257
1257 p = ngx_palloc(pool, escaped->len);
1258 p = ngx_pnalloc(pool, escaped->len);
12581259 if (p == NULL) {
12591260 return NGX_ERROR;
12601261 }
13251326 len += header[i].key.len + 2 + header[i].value.len + 2;
13261327 }
13271328
1328 p = ngx_palloc(cf->pool, len);
1329 p = ngx_pnalloc(cf->pool, len);
13291330 if (p == NULL) {
13301331 return NGX_CONF_ERROR;
13311332 }
235235 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
236236 ngx_mail_core_srv_conf_t *cscf)
237237 {
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);
242242 if (s->salt.data == NULL) {
243243 return NGX_ERROR;
244244 }
287287 "mail auth plain: \"%V\"", &arg[n]);
288288 #endif
289289
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));
291291 if (plain.data == NULL){
292292 return NGX_ERROR;
293293 }
343343 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
344344 "mail auth login username: \"%V\"", &arg[0]);
345345
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));
347347 if (s->login.data == NULL){
348348 return NGX_ERROR;
349349 }
373373 "mail auth login password: \"%V\"", &arg[0]);
374374 #endif
375375
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));
377378 if (s->passwd.data == NULL){
378379 return NGX_ERROR;
379380 }
401402 ngx_str_t salt;
402403 ngx_uint_t n;
403404
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);
405406 if (p == NULL) {
406407 return NGX_ERROR;
407408 }
433434 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
434435 "mail auth cram-md5: \"%V\"", &arg[0]);
435436
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));
437438 if (s->login.data == NULL){
438439 return NGX_ERROR;
439440 }
258258
259259 if (s->tagged_line.len < s->tag.len + s->text.len + s->out.len) {
260260 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);
262262 if (s->tagged_line.data == NULL) {
263263 ngx_mail_close_connection(c);
264264 return;
316316 }
317317
318318 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);
320320 if (s->login.data == NULL) {
321321 return NGX_ERROR;
322322 }
324324 ngx_memcpy(s->login.data, arg[0].data, s->login.len);
325325
326326 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);
328328 if (s->passwd.data == NULL) {
329329 return NGX_ERROR;
330330 }
182182 }
183183 }
184184
185 p = ngx_palloc(cf->pool, size);
185 p = ngx_pnalloc(cf->pool, size);
186186 if (p == NULL) {
187187 return NGX_CONF_ERROR;
188188 }
215215
216216 size += sizeof(" STARTTLS") - 1;
217217
218 p = ngx_palloc(cf->pool, size);
218 p = ngx_pnalloc(cf->pool, size);
219219 if (p == NULL) {
220220 return NGX_CONF_ERROR;
221221 }
232232 size = (auth - conf->capability.data) + sizeof(CRLF) - 1
233233 + sizeof(" STARTTLS LOGINDISABLED") - 1;
234234
235 p = ngx_palloc(cf->pool, size);
235 p = ngx_pnalloc(cf->pool, size);
236236 if (p == NULL) {
237237 return NGX_CONF_ERROR;
238238 }
4545 return;
4646 }
4747
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);
4949 if (s->out.data == NULL) {
5050 ngx_mail_session_internal_server_error(s);
5151 return;
296296
297297 arg = s->args.elts;
298298 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);
300300 if (s->login.data == NULL) {
301301 return NGX_ERROR;
302302 }
323323
324324 arg = s->args.elts;
325325 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);
327327 if (s->passwd.data == NULL) {
328328 return NGX_ERROR;
329329 }
416416 arg = s->args.elts;
417417
418418 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);
420420 if (s->login.data == NULL) {
421421 return NGX_ERROR;
422422 }
424424 ngx_memcpy(s->login.data, arg[0].data, s->login.len);
425425
426426 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);
428428 if (s->passwd.data == NULL) {
429429 return NGX_ERROR;
430430 }
182182 size += sizeof("SASL LOGIN PLAIN" CRLF) - 1;
183183 }
184184
185 p = ngx_palloc(cf->pool, size);
185 p = ngx_pnalloc(cf->pool, size);
186186 if (p == NULL) {
187187 return NGX_CONF_ERROR;
188188 }
212212
213213 size += sizeof("STLS" CRLF) - 1;
214214
215 p = ngx_palloc(cf->pool, size);
215 p = ngx_pnalloc(cf->pool, size);
216216 if (p == NULL) {
217217 return NGX_CONF_ERROR;
218218 }
235235 }
236236
237237
238 p = ngx_palloc(cf->pool, stls_only_size);
238 p = ngx_pnalloc(cf->pool, stls_only_size);
239239 if (p == NULL) {
240240 return NGX_CONF_ERROR;
241241 }
252252 s->connection->log->action = "sending user name to upstream";
253253
254254 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);
256256 if (line.data == NULL) {
257257 ngx_mail_proxy_internal_server_error(s);
258258 return;
271271 s->connection->log->action = "sending password to upstream";
272272
273273 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);
275275 if (line.data == NULL) {
276276 ngx_mail_proxy_internal_server_error(s);
277277 return;
368368
369369 line.len = s->tag.len + sizeof("LOGIN ") - 1
370370 + 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);
372372 if (line.data == NULL) {
373373 ngx_mail_proxy_internal_server_error(s);
374374 return;
387387 s->connection->log->action = "sending user name to upstream";
388388
389389 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);
391391 if (line.data == NULL) {
392392 ngx_mail_proxy_internal_server_error(s);
393393 return;
407407 s->connection->log->action = "sending password to upstream";
408408
409409 line.len = s->passwd.len + 2;
410 line.data = ngx_palloc(c->pool, line.len);
410 line.data = ngx_pnalloc(c->pool, line.len);
411411 if (line.data == NULL) {
412412 ngx_mail_proxy_internal_server_error(s);
413413 return;
504504 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
505505
506506 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);
508508 if (line.data == NULL) {
509509 ngx_mail_proxy_internal_server_error(s);
510510 return;
534534 + s->esmtp + s->smtp_helo.len
535535 + s->connection->addr_text.len + s->login.len + s->host.len;
536536
537 line.data = ngx_palloc(c->pool, line.len);
537 line.data = ngx_pnalloc(c->pool, line.len);
538538 if (line.data == NULL) {
539539 ngx_mail_proxy_internal_server_error(s);
540540 return;
505505
506506 s->smtp_helo.len = arg[0].len;
507507
508 s->smtp_helo.data = ngx_palloc(c->pool, arg[0].len);
508 s->smtp_helo.data = ngx_pnalloc(c->pool, arg[0].len);
509509 if (s->smtp_helo.data == NULL) {
510510 return NGX_ERROR;
511511 }
159159
160160 size = sizeof("220 ESMTP ready" CRLF) - 1 + cscf->server_name.len;
161161
162 p = ngx_palloc(cf->pool, size);
162 p = ngx_pnalloc(cf->pool, size);
163163 if (p == NULL) {
164164 return NGX_CONF_ERROR;
165165 }
174174
175175 size = sizeof("250 " CRLF) - 1 + cscf->server_name.len;
176176
177 p = ngx_palloc(cf->pool, size);
177 p = ngx_pnalloc(cf->pool, size);
178178 if (p == NULL) {
179179 return NGX_CONF_ERROR;
180180 }
208208 }
209209 }
210210
211 p = ngx_palloc(cf->pool, size);
211 p = ngx_pnalloc(cf->pool, size);
212212 if (p == NULL) {
213213 return NGX_CONF_ERROR;
214214 }
246246
247247 size += sizeof("250 STARTTLS" CRLF) - 1;
248248
249 p = ngx_palloc(cf->pool, size);
249 p = ngx_pnalloc(cf->pool, size);
250250 if (p == NULL) {
251251 return NGX_CONF_ERROR;
252252 }
267267 size = (auth - conf->capability.data)
268268 + sizeof("250 STARTTLS" CRLF) - 1;
269269
270 p = ngx_palloc(cf->pool, size);
270 p = ngx_pnalloc(cf->pool, size);
271271 if (p == NULL) {
272272 return NGX_CONF_ERROR;
273273 }
128128
129129 m->query.len = NGX_MYSQL_CMDPKT_LEN + ngx_mysql_command_query.len;
130130
131 m->query.data = ngx_palloc(r->pool, m->query.len);
131 m->query.data = ngx_pnalloc(r->pool, m->query.len);
132132 if (m->query.data == NULL) {
133133 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
134134 return;
214214 len += 20;
215215 }
216216
217 auth = ngx_palloc(m->pool, len);
217 auth = ngx_pnalloc(m->pool, len);
218218 if (auth == NULL) {
219219 ngx_mysql_close(m, NGX_ERROR);
220220 return;
107107 size += ngx_strlen(ngx_argv[i]) + 1;
108108 }
109109
110 title = ngx_palloc(cycle->pool, size);
110 title = ngx_pnalloc(cycle->pool, size);
111111
112112 p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
113113 for (i = 0; i < ngx_argc; i++) {
4242 if (err == 0) {
4343 len = ngx_strlen(value);
4444
45 *encrypted = ngx_palloc(pool, len);
45 *encrypted = ngx_pnalloc(pool, len);
4646 if (*encrypted) {
4747 ngx_memcpy(*encrypted, value, len + 1);
4848 return NGX_OK;
8080 if (value) {
8181 len = ngx_strlen(value);
8282
83 *encrypted = ngx_palloc(pool, len);
83 *encrypted = ngx_pnalloc(pool, len);
8484 if (*encrypted) {
8585 ngx_memcpy(*encrypted, value, len + 1);
8686 }