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

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