aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_auth_basic_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-12-06 14:17:42 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-12-06 14:17:42 +0000
commita19ed3eddd136a51a06e344f3f677c0e31c1a284 (patch)
tree3f05c6671e6cd5e80bda9486cf8adb7288747203 /src/http/modules/ngx_http_auth_basic_module.c
parent8f98581bbf1d163719f53146ff56af403d8cfc94 (diff)
downloadnginx-a19ed3eddd136a51a06e344f3f677c0e31c1a284.tar.gz
nginx-a19ed3eddd136a51a06e344f3f677c0e31c1a284.zip
fix when last htpasswd line has no CR or LF
Diffstat (limited to 'src/http/modules/ngx_http_auth_basic_module.c')
-rw-r--r--src/http/modules/ngx_http_auth_basic_module.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
index 5a4f9d823..d021ef83e 100644
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -154,6 +154,8 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
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_handler(ngx_http_request_t *r)
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);
}