1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
From f2e14e00ff0afdb7e45a595dc4c5f9e50d413b4d Mon Sep 17 00:00:00 2001
From: Jon Simons <jon@jonsimons.org>
Date: Sat, 18 Oct 2014 23:23:26 -0700
Subject: [PATCH] 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>
(cherry picked from commit 2ced24ddd67a261dc364ad4d8958c068c1671ae7)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
---
src/kex.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/kex.c b/src/kex.c
index dedf286..db35183 100644
--- a/src/kex.c
+++ b/src/kex.c
@@ -286,7 +286,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
for (i = 0; i < 10; i++) {
str = buffer_get_ssh_string(packet);
if (str == NULL) {
- break;
+ goto error;
}
if (buffer_add_ssh_string(session->in_hashbuf, str) < 0) {
@@ -333,6 +333,11 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
error:
ssh_string_free(str);
for (i = 0; i < 10; i++) {
+ if (server_kex) {
+ session->server_kex.methods[i] = NULL;
+ } else {
+ session->client_kex.methods[i] = NULL;
+ }
SAFE_FREE(strings[i]);
}
--
2.2.0
|