gssapi: free session->gssapi->user before assigning

To prevent memory leaks with multiple authentication attempts.

Signed-off-by: Pavol Žáčik <pzacik@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Pavol Žáčik
2025-12-18 14:25:35 +01:00
committed by Jakub Jelen
parent 65abae059e
commit d0d45c8915
2 changed files with 2 additions and 0 deletions

View File

@@ -2520,6 +2520,7 @@ int ssh_userauth_gssapi_keyex(ssh_session session)
session->auth.state = SSH_AUTH_STATE_NONE; session->auth.state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_GSSAPI_KEYEX; session->pending_call_state = SSH_PENDING_CALL_AUTH_GSSAPI_KEYEX;
SAFE_FREE(session->gssapi->user);
session->gssapi->user = strdup(session->opts.username); session->gssapi->user = strdup(session->opts.username);
if (session->gssapi->user == NULL) { if (session->gssapi->user == NULL) {
ssh_set_error_oom(session); ssh_set_error_oom(session);

View File

@@ -1177,6 +1177,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_request)
received_mic.length = ssh_string_len(mic_token_string); received_mic.length = ssh_string_len(mic_token_string);
received_mic.value = ssh_string_data(mic_token_string); received_mic.value = ssh_string_data(mic_token_string);
SAFE_FREE(session->gssapi->user);
session->gssapi->user = strdup(msg->auth_request.username); session->gssapi->user = strdup(msg->auth_request.username);
buf = ssh_gssapi_build_mic(session, "gssapi-keyex"); buf = ssh_gssapi_build_mic(session, "gssapi-keyex");
if (buf == NULL) { if (buf == NULL) {