1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-17 04:22:32 +03:00

Prevent possible double free of hostkey (#1452)

NULL server hostkey based on fuzzer failure case.
This commit is contained in:
Will Cosgrove
2024-09-10 09:35:26 -07:00
committed by GitHub
parent 9d9ee7807d
commit b346541847

View File

@@ -469,8 +469,11 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
buf.dataptr = buf.data;
buf.dataptr++; /* advance past type */
if(session->server_hostkey)
if(session->server_hostkey) {
LIBSSH2_FREE(session, session->server_hostkey);
session->server_hostkey = NULL;
session->server_hostkey_len = 0;
}
if(_libssh2_copy_string(session, &buf, &(session->server_hostkey),
&host_key_len)) {