Blame SOURCES/0068-curl-7.29.0-CVE-2018-14618.patch

230636
From 3bae605ce08375120f34761e5a4364253276ec88 Mon Sep 17 00:00:00 2001
230636
From: Daniel Stenberg <daniel@haxx.se>
230636
Date: Sat, 4 Nov 2017 16:42:21 +0100
230636
Subject: [PATCH 1/2] ntlm: avoid malloc(0) for zero length passwords
230636
230636
It triggers an assert() when built with memdebug since malloc(0) may
230636
return NULL *or* a valid pointer.
230636
230636
Detected by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4054
230636
230636
Assisted-by: Max Dymond
230636
Closes #2054
230636
230636
Upstream-commit: 685ef130575cdcf63fe9547757d88a49a40ef281
230636
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
230636
---
230636
 lib/curl_ntlm_core.c | 2 +-
230636
 1 file changed, 1 insertion(+), 1 deletion(-)
230636
230636
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
230636
index 8f3c00d..459f6f9 100644
230636
--- a/lib/curl_ntlm_core.c
230636
+++ b/lib/curl_ntlm_core.c
230636
@@ -385,7 +385,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
230636
                                    unsigned char *ntbuffer /* 21 bytes */)
230636
 {
230636
   size_t len = strlen(password);
230636
-  unsigned char *pw = malloc(len * 2);
230636
+  unsigned char *pw = len ? malloc(len * 2) : strdup("");
230636
   CURLcode result;
230636
   if(!pw)
230636
     return CURLE_OUT_OF_MEMORY;
230636
-- 
230636
2.17.1
230636
230636
230636
From 4c20ad72a35f44c31241a916ccf9a789a01d5ab8 Mon Sep 17 00:00:00 2001
230636
From: Daniel Stenberg <daniel@haxx.se>
230636
Date: Mon, 13 Aug 2018 10:35:52 +0200
230636
Subject: [PATCH 2/2] Curl_ntlm_core_mk_nt_hash: return error on too long
230636
 password
230636
230636
... since it would cause an integer overflow if longer than (max size_t
230636
/ 2).
230636
230636
This is CVE-2018-14618
230636
230636
Bug: https://curl.haxx.se/docs/CVE-2018-14618.html
230636
Closes #2756
230636
Reported-by: Zhaoyang Wu
230636
230636
Upstream-commit: 57d299a499155d4b327e341c6024e293b0418243
230636
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
230636
---
230636
 lib/curl_ntlm_core.c | 14 +++++++++++++-
230636
 1 file changed, 13 insertions(+), 1 deletion(-)
230636
230636
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
230636
index 459f6f9..1b6551f 100644
230636
--- a/lib/curl_ntlm_core.c
230636
+++ b/lib/curl_ntlm_core.c
230636
@@ -128,6 +128,15 @@ static void setup_des_key(const unsigned char *key_56,
230636
 
230636
 #else /* defined(USE_SSLEAY) */
230636
 
230636
+#ifndef SIZE_T_MAX
230636
+/* some limits.h headers have this defined, some don't */
230636
+#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
230636
+#define SIZE_T_MAX 18446744073709551615U
230636
+#else
230636
+#define SIZE_T_MAX 4294967295U
230636
+#endif
230636
+#endif
230636
+
230636
 /*
230636
  * Turns a 56 bit key into the 64 bit, odd parity key.  Used by GnuTLS and NSS.
230636
  */
230636
@@ -385,8 +394,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
230636
                                    unsigned char *ntbuffer /* 21 bytes */)
230636
 {
230636
   size_t len = strlen(password);
230636
-  unsigned char *pw = len ? malloc(len * 2) : strdup("");
230636
+  unsigned char *pw;
230636
   CURLcode result;
230636
+  if(len > SIZE_T_MAX/2) /* avoid integer overflow */
230636
+    return CURLE_OUT_OF_MEMORY;
230636
+  pw = len ? malloc(len * 2) : strdup("");
230636
   if(!pw)
230636
     return CURLE_OUT_OF_MEMORY;
230636
 
230636
-- 
230636
2.17.1
230636