Use hash_find rather than hash_iter for unpwd check.

This commit is contained in:
Roger A. Light 2020-08-18 15:34:57 +01:00
parent b66ffb8039
commit 18e79eac22

View File

@ -888,7 +888,7 @@ static int mosquitto__memcmp_const(const void *a, const void *b, size_t len)
int mosquitto_unpwd_check_default(struct mosquitto_db *db, struct mosquitto *context)
{
struct mosquitto__unpwd *u, *tmp;
struct mosquitto__unpwd *u;
struct mosquitto__unpwd *unpwd_ref;
#ifdef WITH_TLS
unsigned char hash[EVP_MAX_MD_SIZE];
@ -921,8 +921,8 @@ int mosquitto_unpwd_check_default(struct mosquitto_db *db, struct mosquitto *con
}
}
HASH_ITER(hh, unpwd_ref, u, tmp){
if(!strcmp(u->username, context->username)){
HASH_FIND(hh, unpwd_ref, context->username, strlen(context->username), u);
if(u){
if(u->password){
if(context->password){
#ifdef WITH_TLS
@ -948,7 +948,6 @@ int mosquitto_unpwd_check_default(struct mosquitto_db *db, struct mosquitto *con
return MOSQ_ERR_SUCCESS;
}
}
}
return MOSQ_ERR_AUTH;
}