mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
CVE-2014-8132: Fixup error path in ssh_packet_kexinit()
Before this change, dangling pointers can be unintentionally left in the respective next_crypto kex methods slots. Ensure to set all slots to NULL in the error-out path. Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
b7b535816d
commit
c2aed4ca78
@@ -368,7 +368,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
|
|||||||
for (i = 0; i < KEX_METHODS_SIZE; i++) {
|
for (i = 0; i < KEX_METHODS_SIZE; i++) {
|
||||||
str = buffer_get_ssh_string(packet);
|
str = buffer_get_ssh_string(packet);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
break;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = buffer_add_ssh_string(session->in_hashbuf, str);
|
rc = buffer_add_ssh_string(session->in_hashbuf, str);
|
||||||
@@ -443,6 +443,11 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
|
|||||||
error:
|
error:
|
||||||
ssh_string_free(str);
|
ssh_string_free(str);
|
||||||
for (i = 0; i < SSH_KEX_METHODS; i++) {
|
for (i = 0; i < SSH_KEX_METHODS; i++) {
|
||||||
|
if (server_kex) {
|
||||||
|
session->next_crypto->client_kex.methods[i] = NULL;
|
||||||
|
} else { /* client */
|
||||||
|
session->next_crypto->server_kex.methods[i] = NULL;
|
||||||
|
}
|
||||||
SAFE_FREE(strings[i]);
|
SAFE_FREE(strings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user