Mercurial > hg > nginx-quic
comparison src/mail/ngx_mail_handler.c @ 2049:2a92804f4109
*) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 17 Jun 2008 15:00:30 +0000 |
parents | e584e946e198 |
children | cbf6f2eb57ad |
comparison
equal
deleted
inserted
replaced
2048:824615f3b4ec | 2049:2a92804f4109 |
---|---|
234 | 234 |
235 ngx_int_t | 235 ngx_int_t |
236 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c, | 236 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c, |
237 ngx_mail_core_srv_conf_t *cscf) | 237 ngx_mail_core_srv_conf_t *cscf) |
238 { | 238 { |
239 s->salt.data = ngx_palloc(c->pool, | 239 s->salt.data = ngx_pnalloc(c->pool, |
240 sizeof(" <18446744073709551616.@>" CRLF) - 1 | 240 sizeof(" <18446744073709551616.@>" CRLF) - 1 |
241 + NGX_TIME_T_LEN | 241 + NGX_TIME_T_LEN |
242 + cscf->server_name.len); | 242 + cscf->server_name.len); |
243 if (s->salt.data == NULL) { | 243 if (s->salt.data == NULL) { |
244 return NGX_ERROR; | 244 return NGX_ERROR; |
245 } | 245 } |
246 | 246 |
247 s->salt.len = ngx_sprintf(s->salt.data, "<%ul.%T@%V>" CRLF, | 247 s->salt.len = ngx_sprintf(s->salt.data, "<%ul.%T@%V>" CRLF, |
286 #if (NGX_DEBUG_MAIL_PASSWD) | 286 #if (NGX_DEBUG_MAIL_PASSWD) |
287 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | 287 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
288 "mail auth plain: \"%V\"", &arg[n]); | 288 "mail auth plain: \"%V\"", &arg[n]); |
289 #endif | 289 #endif |
290 | 290 |
291 plain.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[n].len)); | 291 plain.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[n].len)); |
292 if (plain.data == NULL){ | 292 if (plain.data == NULL){ |
293 return NGX_ERROR; | 293 return NGX_ERROR; |
294 } | 294 } |
295 | 295 |
296 if (ngx_decode_base64(&plain, &arg[n]) != NGX_OK) { | 296 if (ngx_decode_base64(&plain, &arg[n]) != NGX_OK) { |
342 arg = s->args.elts; | 342 arg = s->args.elts; |
343 | 343 |
344 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | 344 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
345 "mail auth login username: \"%V\"", &arg[0]); | 345 "mail auth login username: \"%V\"", &arg[0]); |
346 | 346 |
347 s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | 347 s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len)); |
348 if (s->login.data == NULL){ | 348 if (s->login.data == NULL){ |
349 return NGX_ERROR; | 349 return NGX_ERROR; |
350 } | 350 } |
351 | 351 |
352 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { | 352 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { |
372 #if (NGX_DEBUG_MAIL_PASSWD) | 372 #if (NGX_DEBUG_MAIL_PASSWD) |
373 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | 373 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
374 "mail auth login password: \"%V\"", &arg[0]); | 374 "mail auth login password: \"%V\"", &arg[0]); |
375 #endif | 375 #endif |
376 | 376 |
377 s->passwd.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | 377 s->passwd.data = ngx_pnalloc(c->pool, |
378 ngx_base64_decoded_length(arg[0].len)); | |
378 if (s->passwd.data == NULL){ | 379 if (s->passwd.data == NULL){ |
379 return NGX_ERROR; | 380 return NGX_ERROR; |
380 } | 381 } |
381 | 382 |
382 if (ngx_decode_base64(&s->passwd, &arg[0]) != NGX_OK) { | 383 if (ngx_decode_base64(&s->passwd, &arg[0]) != NGX_OK) { |
400 { | 401 { |
401 u_char *p; | 402 u_char *p; |
402 ngx_str_t salt; | 403 ngx_str_t salt; |
403 ngx_uint_t n; | 404 ngx_uint_t n; |
404 | 405 |
405 p = ngx_palloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2); | 406 p = ngx_pnalloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2); |
406 if (p == NULL) { | 407 if (p == NULL) { |
407 return NGX_ERROR; | 408 return NGX_ERROR; |
408 } | 409 } |
409 | 410 |
410 salt.data = ngx_cpymem(p, prefix, len); | 411 salt.data = ngx_cpymem(p, prefix, len); |
432 arg = s->args.elts; | 433 arg = s->args.elts; |
433 | 434 |
434 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | 435 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
435 "mail auth cram-md5: \"%V\"", &arg[0]); | 436 "mail auth cram-md5: \"%V\"", &arg[0]); |
436 | 437 |
437 s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); | 438 s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len)); |
438 if (s->login.data == NULL){ | 439 if (s->login.data == NULL){ |
439 return NGX_ERROR; | 440 return NGX_ERROR; |
440 } | 441 } |
441 | 442 |
442 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { | 443 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { |