Mercurial > hg > nginx
changeset 890:6356b34cf027
fix when last htpasswd line has no CR or LF
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 06 Dec 2006 14:17:42 +0000 |
parents | a9a7e4b1a72b |
children | 8a3ba663be1a |
files | src/http/modules/ngx_http_auth_basic_module.c |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_auth_basic_module.c Wed Dec 06 11:33:18 2006 +0000 +++ b/src/http/modules/ngx_http_auth_basic_module.c Wed Dec 06 14:17:42 2006 +0000 @@ -154,6 +154,8 @@ offset = 0; for ( ;; ) { + i = left; + n = ngx_read_file(&file, buf + left, NGX_HTTP_AUTH_BUF_SIZE - left, offset); @@ -228,6 +230,18 @@ ngx_http_auth_basic_close(&file); + if (state == sw_passwd) { + pwd.len = i - passwd; + pwd.data = ngx_palloc(r->pool, pwd.len + 1); + if (pwd.data == NULL) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + + ngx_cpystrn(pwd.data, &buf[passwd], pwd.len + 1); + + return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &alcf->realm); + } + return ngx_http_auth_basic_set_realm(r, &alcf->realm); }