1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-30 06:35:23 +00:00

Cleanup: Inlined strlen() into get_hash() as it is the only way get_hash() is ever called

This commit is contained in:
Philipp Schafft 2023-02-13 11:38:15 +00:00
parent c7c4a63b66
commit 9b758ca65c

View File

@ -69,14 +69,14 @@ static void htpasswd_clear(auth_t *self)
/* md5 hash */ /* md5 hash */
static char *get_hash(const char *data, int len) static char *get_hash(const char *data)
{ {
struct MD5Context context; struct MD5Context context;
unsigned char digest[16]; unsigned char digest[16];
MD5Init(&context); MD5Init(&context);
MD5Update(&context, (const unsigned char *)data, len); MD5Update(&context, (const unsigned char *)data, strlen(data));
MD5Final(digest, &context); MD5Final(digest, &context);
@ -203,7 +203,7 @@ static auth_result htpasswd_auth (auth_client *auth_user)
char *hashed_pw; char *hashed_pw;
thread_rwlock_unlock (&htpasswd->file_rwlock); 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) { if (strcmp (found->pass, hashed_pw) == 0) {
free (hashed_pw); free (hashed_pw);
return AUTH_OK; return AUTH_OK;
@ -291,7 +291,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
return AUTH_FAILED; return AUTH_FAILED;
} }
hashed_password = get_hash(password, strlen(password)); hashed_password = get_hash(password);
if (hashed_password) { if (hashed_password) {
fprintf(passwdfile, "%s:%s\n", username, hashed_password); fprintf(passwdfile, "%s:%s\n", username, hashed_password);
free(hashed_password); free(hashed_password);