Blame SOURCES/0009-libssh2-1.8.0-CVE-2019-3863.patch

12243c
From 9ed3c716b63c77e9b52f71f2dae5464ade6143df Mon Sep 17 00:00:00 2001
12243c
From: Kamil Dudka <kdudka@redhat.com>
12243c
Date: Tue, 19 Mar 2019 13:47:41 +0100
12243c
Subject: [PATCH] Resolves: CVE-2019-3863 - fix integer overflow in user
12243c
 authenticate keyboard interactive
12243c
12243c
... that allows out-of-bounds writes
12243c
12243c
Upstream-Patch: https://libssh2.org/1.8.0-CVE/CVE-2019-3863.patch
12243c
---
12243c
 src/userauth.c | 13 +++++++++++--
12243c
 1 file changed, 11 insertions(+), 2 deletions(-)
12243c
12243c
diff --git a/src/userauth.c b/src/userauth.c
12243c
index 3946cf9..ee924c5 100644
12243c
--- a/src/userauth.c
12243c
+++ b/src/userauth.c
12243c
@@ -1808,8 +1808,17 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
12243c
 
12243c
             for(i = 0; i < session->userauth_kybd_num_prompts; i++) {
12243c
                 /* string    response[1] (ISO-10646 UTF-8) */
12243c
-                session->userauth_kybd_packet_len +=
12243c
-                    4 + session->userauth_kybd_responses[i].length;
12243c
+                 if(session->userauth_kybd_responses[i].length <=
12243c
+                   (SIZE_MAX - 4 - session->userauth_kybd_packet_len) ) {
12243c
+                    session->userauth_kybd_packet_len +=
12243c
+                        4 + session->userauth_kybd_responses[i].length;
12243c
+                }
12243c
+                else {
12243c
+                    _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
12243c
+                                   "Unable to allocate memory for keyboard-"
12243c
+                                   "interactive response packet");
12243c
+                    goto cleanup;
12243c
+                }
12243c
             }
12243c
 
12243c
             /* A new userauth_kybd_data area is to be allocated, free the
12243c
-- 
12243c
2.17.2
12243c