1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

auth: Don't leak memory on error in info request callback.

Found by Coverity.
This commit is contained in:
Andreas Schneider
2012-10-08 21:10:06 +02:00
parent 96e0301b58
commit 66045054f4

View File

@@ -1741,15 +1741,16 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
tmp = buffer_get_ssh_string(packet); tmp = buffer_get_ssh_string(packet);
buffer_get_u32(packet, &nprompts); buffer_get_u32(packet, &nprompts);
if (name == NULL || instruction == NULL || tmp == NULL) { /* We don't care about tmp */
ssh_string_free(tmp);
if (name == NULL || instruction == NULL) {
ssh_string_free(name); ssh_string_free(name);
ssh_string_free(instruction); ssh_string_free(instruction);
/* tmp if empty if we got here */
ssh_set_error(session, SSH_FATAL, "Invalid USERAUTH_INFO_REQUEST msg"); ssh_set_error(session, SSH_FATAL, "Invalid USERAUTH_INFO_REQUEST msg");
leave_function(); leave_function();
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
ssh_string_free(tmp);
if (session->kbdint == NULL) { if (session->kbdint == NULL) {
session->kbdint = ssh_kbdint_new(); session->kbdint = ssh_kbdint_new();
@@ -1770,6 +1771,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
if (session->kbdint->name == NULL) { if (session->kbdint->name == NULL) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
ssh_kbdint_free(session->kbdint); ssh_kbdint_free(session->kbdint);
ssh_string_free(instruction);
leave_function(); leave_function();
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }