1
1

messages: Fix error path of ssh_packet_userauth_info_response.

This fixes a memory leak on error.
Этот коммит содержится в:
Andreas Schneider 2012-10-05 11:01:55 +02:00
родитель 8567fc8d8c
Коммит fd2064d0b4

Просмотреть файл

@ -716,8 +716,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
if (session->kbdint == NULL) { if (session->kbdint == NULL) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
leave_function(); goto error;
return SSH_PACKET_USED;
} }
} }
@ -729,8 +728,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
nanswers, nanswers); nanswers, nanswers);
ssh_kbdint_free(session->kbdint); ssh_kbdint_free(session->kbdint);
session->kbdint = NULL; session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED; goto error;
} }
if(nanswers != session->kbdint->nprompts) { if(nanswers != session->kbdint->nprompts) {
@ -745,8 +744,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
ssh_set_error_oom(session); ssh_set_error_oom(session);
ssh_kbdint_free(session->kbdint); ssh_kbdint_free(session->kbdint);
session->kbdint = NULL; session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED; goto error;
} }
memset(session->kbdint->answers, 0, nanswers * sizeof(char *)); memset(session->kbdint->answers, 0, nanswers * sizeof(char *));
@ -757,8 +756,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
session->kbdint->nanswers = i; session->kbdint->nanswers = i;
ssh_kbdint_free(session->kbdint); ssh_kbdint_free(session->kbdint);
session->kbdint = NULL; session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED; goto error;
} }
session->kbdint->answers[i] = ssh_string_to_char(tmp); session->kbdint->answers[i] = ssh_string_to_char(tmp);
ssh_string_free(tmp); ssh_string_free(tmp);
@ -767,23 +766,20 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
session->kbdint->nanswers = i; session->kbdint->nanswers = i;
ssh_kbdint_free(session->kbdint); ssh_kbdint_free(session->kbdint);
session->kbdint = NULL; session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED; goto error;
} }
} }
goto end; ssh_message_queue(session,msg);
leave_function();
return SSH_PACKET_USED;
error: error:
ssh_message_free(msg); ssh_message_free(msg);
leave_function(); leave_function();
return SSH_PACKET_USED; return SSH_PACKET_USED;
end:
ssh_message_queue(session,msg);
leave_function();
return SSH_PACKET_USED;
} }
#endif #endif