Blame SOURCES/0003-libssh2-1.8.0-CVE-2019-3857.patch

12243c
From cbd8d5c44701f97eccd6602e3d745fc37a8d7ff4 Mon Sep 17 00:00:00 2001
12243c
From: Kamil Dudka <kdudka@redhat.com>
12243c
Date: Tue, 19 Mar 2019 13:29:35 +0100
12243c
Subject: [PATCH 1/2] Resolves: CVE-2019-3857 - fix integer overflow in SSH
12243c
 packet processing channel
12243c
12243c
... resulting in out of bounds write
12243c
12243c
Upstream-Patch: https://libssh2.org/1.8.0-CVE/CVE-2019-3857.patch
12243c
---
12243c
 include/libssh2.h | 12 ++++++++++++
12243c
 src/packet.c      | 11 +++++++++--
12243c
 2 files changed, 21 insertions(+), 2 deletions(-)
12243c
12243c
diff --git a/include/libssh2.h b/include/libssh2.h
12243c
index 34d2842..e25c380 100644
12243c
--- a/include/libssh2.h
12243c
+++ b/include/libssh2.h
12243c
@@ -145,6 +145,18 @@ typedef int libssh2_socket_t;
12243c
 #define LIBSSH2_INVALID_SOCKET -1
12243c
 #endif /* WIN32 */
12243c
 
12243c
+#ifndef SIZE_MAX
12243c
+#if _WIN64
12243c
+#define SIZE_MAX 0xFFFFFFFFFFFFFFFF
12243c
+#else
12243c
+#define SIZE_MAX 0xFFFFFFFF
12243c
+#endif
12243c
+#endif
12243c
+
12243c
+#ifndef UINT_MAX
12243c
+#define UINT_MAX 0xFFFFFFFF
12243c
+#endif
12243c
+
12243c
 /*
12243c
  * Determine whether there is small or large file support on windows.
12243c
  */
12243c
diff --git a/src/packet.c b/src/packet.c
12243c
index 5f1feb8..aa10633 100644
12243c
--- a/src/packet.c
12243c
+++ b/src/packet.c
12243c
@@ -815,8 +815,15 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
12243c
                         /* set signal name (without SIG prefix) */
12243c
                         uint32_t namelen =
12243c
                             _libssh2_ntohu32(data + 9 + sizeof("exit-signal"));
12243c
-                        channelp->exit_signal =
12243c
-                            LIBSSH2_ALLOC(session, namelen + 1);
12243c
+
12243c
+                        if(namelen <= UINT_MAX - 1) {
12243c
+                            channelp->exit_signal =
12243c
+                                LIBSSH2_ALLOC(session, namelen + 1);
12243c
+                        }
12243c
+                        else {
12243c
+                            channelp->exit_signal = NULL;
12243c
+                        }
12243c
+
12243c
                         if (!channelp->exit_signal)
12243c
                             rc = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
12243c
                                                 "memory for signal name");
12243c
-- 
12243c
2.17.2
12243c
12243c
12243c
From 0708c71871976ccf6d45fd0971a079d271413f92 Mon Sep 17 00:00:00 2001
12243c
From: Michael Buckley <michael@buckleyisms.com>
12243c
Date: Mon, 18 Mar 2019 15:07:12 -0700
12243c
Subject: [PATCH 2/2] Move fallback SIZE_MAX and UINT_MAX to libssh2_priv.h
12243c
12243c
Upstream-commit: 31d0b1a8530b959bd12c2074dc6e883e1eda8207
12243c
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
12243c
---
12243c
 include/libssh2.h  | 12 ------------
12243c
 src/libssh2_priv.h | 12 ++++++++++++
12243c
 2 files changed, 12 insertions(+), 12 deletions(-)
12243c
12243c
diff --git a/include/libssh2.h b/include/libssh2.h
12243c
index e25c380..34d2842 100644
12243c
--- a/include/libssh2.h
12243c
+++ b/include/libssh2.h
12243c
@@ -145,18 +145,6 @@ typedef int libssh2_socket_t;
12243c
 #define LIBSSH2_INVALID_SOCKET -1
12243c
 #endif /* WIN32 */
12243c
 
12243c
-#ifndef SIZE_MAX
12243c
-#if _WIN64
12243c
-#define SIZE_MAX 0xFFFFFFFFFFFFFFFF
12243c
-#else
12243c
-#define SIZE_MAX 0xFFFFFFFF
12243c
-#endif
12243c
-#endif
12243c
-
12243c
-#ifndef UINT_MAX
12243c
-#define UINT_MAX 0xFFFFFFFF
12243c
-#endif
12243c
-
12243c
 /*
12243c
  * Determine whether there is small or large file support on windows.
12243c
  */
12243c
diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h
12243c
index b4296a2..bb5d1a5 100644
12243c
--- a/src/libssh2_priv.h
12243c
+++ b/src/libssh2_priv.h
12243c
@@ -146,6 +146,18 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
12243c
 
12243c
 #endif
12243c
 
12243c
+#ifndef SIZE_MAX
12243c
+#if _WIN64
12243c
+#define SIZE_MAX 0xFFFFFFFFFFFFFFFF
12243c
+#else
12243c
+#define SIZE_MAX 0xFFFFFFFF
12243c
+#endif
12243c
+#endif
12243c
+
12243c
+#ifndef UINT_MAX
12243c
+#define UINT_MAX 0xFFFFFFFF
12243c
+#endif
12243c
+
12243c
 /* RFC4253 section 6.1 Maximum Packet Length says:
12243c
  *
12243c
  * "All implementations MUST be able to process packets with
12243c
-- 
12243c
2.17.2
12243c