From 9b758ca65cbefaa678f9983fd6a2180c8a974680 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Mon, 13 Feb 2023 11:38:15 +0000 Subject: [PATCH] Cleanup: Inlined strlen() into get_hash() as it is the only way get_hash() is ever called --- src/auth_htpasswd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auth_htpasswd.c b/src/auth_htpasswd.c index 48bf347e..a5d726e8 100644 --- a/src/auth_htpasswd.c +++ b/src/auth_htpasswd.c @@ -69,14 +69,14 @@ static void htpasswd_clear(auth_t *self) /* md5 hash */ -static char *get_hash(const char *data, int len) +static char *get_hash(const char *data) { struct MD5Context context; unsigned char digest[16]; MD5Init(&context); - MD5Update(&context, (const unsigned char *)data, len); + MD5Update(&context, (const unsigned char *)data, strlen(data)); MD5Final(digest, &context); @@ -203,7 +203,7 @@ static auth_result htpasswd_auth (auth_client *auth_user) char *hashed_pw; thread_rwlock_unlock (&htpasswd->file_rwlock); - hashed_pw = get_hash (client->password, strlen (client->password)); + hashed_pw = get_hash(client->password); if (strcmp (found->pass, hashed_pw) == 0) { free (hashed_pw); return AUTH_OK; @@ -291,7 +291,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c return AUTH_FAILED; } - hashed_password = get_hash(password, strlen(password)); + hashed_password = get_hash(password); if (hashed_password) { fprintf(passwdfile, "%s:%s\n", username, hashed_password); free(hashed_password);