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

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