Skip to content

Commit

Permalink
sources/auth_query.c: handle malloc failure
Browse files Browse the repository at this point in the history
  • Loading branch information
chipitsine committed Jan 12, 2024
1 parent 360f52d commit 34dab4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sources/auth_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ int od_auth_query(od_client_t *client, char *peer)
user->value_len, user->value);
/* unlock hashmap entry */
password->password_len = cache_value->passwd_len;
if (password->password == NULL) {
goto error;
}
if (cache_value->passwd_len > 0) {
/* */
password->password = malloc(password->password_len + 1);
Expand Down Expand Up @@ -259,6 +262,9 @@ int od_auth_query(od_client_t *client, char *peer)
}
cache_value->passwd_len = password->password_len;
cache_value->passwd = malloc(password->password_len);
if (cache_value->passwd == NULL) {
goto error;
}
strncpy(cache_value->passwd, password->password,
cache_value->passwd_len);

Expand Down

0 comments on commit 34dab4f

Please sign in to comment.