Skip to content

Commit

Permalink
Fix segfault on empty password (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke authored Nov 13, 2023
1 parent 9a42394 commit e2e3ee6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sources/auth_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ int od_auth_query(od_client_t *client, char *peer)
user->name_len, user->name);
/* unlock hashmap entry */
password->password_len = cache_value->passwd_len;
password->password = malloc(password->password_len + 1);
strncpy(password->password, cache_value->passwd,
cache_value->passwd_len);
password->password[password->password_len] = '\0';
if (cache_value->passwd_len > 0) {
/* */
password->password = malloc(password->password_len + 1);
strncpy(password->password, cache_value->passwd,
cache_value->passwd_len);
password->password[password->password_len] = '\0';
}
od_hashmap_unlock_key(storage->acache, keyhash, &key);
return OK_RESPONSE;
}
Expand Down

0 comments on commit e2e3ee6

Please sign in to comment.