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

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