summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-09-08 18:25:39 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-09-08 18:25:39 -0400
commit89dfbf14a5f9bb19bc89e9c29bffe2f5e8dcdcaa (patch)
treea5e6c2212f490ee2e1368d0d4ba4ba4d8f850130
parent6ad325c659c4f602584c9450242204f410e74952 (diff)
downloadlighttpd1.4-89dfbf14a5f9bb19bc89e9c29bffe2f5e8dcdcaa.tar.gz
lighttpd1.4-89dfbf14a5f9bb19bc89e9c29bffe2f5e8dcdcaa.zip
[mod_auth] http_auth_const_time_memeq_pad()
rename http_auth_const_time_memeq() to http_auth_const_time_memeq_pad() for constant time padded comparison of strings of potentially different length
-rw-r--r--src/http_auth.c2
-rw-r--r--src/http_auth.h4
-rw-r--r--src/mod_authn_file.c2
3 files changed, 5 insertions, 3 deletions
diff --git a/src/http_auth.c b/src/http_auth.c
index d3d3f6dd..24c2319a 100644
--- a/src/http_auth.c
+++ b/src/http_auth.c
@@ -51,7 +51,7 @@ void http_auth_backend_set (const http_auth_backend_t *backend)
}
-int http_auth_const_time_memeq (const char *a, const size_t alen, const char *b, const size_t blen)
+int http_auth_const_time_memeq_pad (const void *a, const size_t alen, const void *b, const size_t blen)
{
/* constant time memory compare, unless compiler figures it out
* (similar to mod_secdownload.c:const_time_memeq()) */
diff --git a/src/http_auth.h b/src/http_auth.h
index 5b9aacbd..64a32da7 100644
--- a/src/http_auth.h
+++ b/src/http_auth.h
@@ -69,7 +69,9 @@ const http_auth_scheme_t * http_auth_scheme_get (const buffer *name);
void http_auth_scheme_set (const http_auth_scheme_t *scheme);
const http_auth_backend_t * http_auth_backend_get (const buffer *name);
void http_auth_backend_set (const http_auth_backend_t *backend);
-int http_auth_const_time_memeq (const char *a, size_t alen, const char *b, size_t blen);
+
+__attribute_pure__
+int http_auth_const_time_memeq_pad (const void *a, size_t alen, const void *b, size_t blen);
void http_auth_setenv(connection *con, const char *username, size_t ulen, const char *auth_type, size_t alen);
diff --git a/src/mod_authn_file.c b/src/mod_authn_file.c
index 1e16075e..6f76794a 100644
--- a/src/mod_authn_file.c
+++ b/src/mod_authn_file.c
@@ -443,7 +443,7 @@ static handler_t mod_authn_file_plain_basic(server *srv, connection *con, void *
mod_authn_file_patch_connection(srv, con, p);
rc = mod_authn_file_htpasswd_get(srv, p->conf.auth_plain_userfile, CONST_BUF_LEN(username), password_buf);
if (0 == rc) {
- rc = http_auth_const_time_memeq(CONST_BUF_LEN(password_buf), pw, strlen(pw)) ? 0 : -1;
+ rc = http_auth_const_time_memeq_pad(CONST_BUF_LEN(password_buf), pw, strlen(pw)) ? 0 : -1;
}
buffer_free(password_buf);
return 0 == rc && http_auth_match_rules(require, username->ptr, NULL, NULL)