Skip to content

Commit

Permalink
sources/auth_query.c: handle malloc failure (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
chipitsine authored Jan 19, 2024
1 parent 360f52d commit 999672b
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 @@ -145,6 +145,9 @@ int od_auth_query(od_client_t *client, char *peer)
if (cache_value->passwd_len > 0) {
/* */
password->password = malloc(password->password_len + 1);
if (password->password == NULL) {
goto error;
}
strncpy(password->password, cache_value->passwd,
cache_value->passwd_len);
password->password[password->password_len] = '\0';
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 999672b

Please sign in to comment.