1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

kex: free server host key before allocating it (again)

Fixes a memory leak when Synology server requests key exchange

Closes #43
This commit is contained in:
Zenju
2015-09-11 15:45:00 +02:00
committed by Daniel Stenberg
parent 3acca4ad15
commit 3768f8aeef

View File

@@ -202,6 +202,10 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
session->server_hostkey_len = _libssh2_ntohu32(exchange_state->s);
exchange_state->s += 4;
if (session->server_hostkey)
LIBSSH2_FREE(session, session->server_hostkey);
session->server_hostkey =
LIBSSH2_ALLOC(session, session->server_hostkey_len);
if (!session->server_hostkey) {