Blame SOURCES/0010-curl-7.61.1-CVE-2019-3822.patch

b91d92
From ab22e3a00f04b458039c21111cfa448051e5777d Mon Sep 17 00:00:00 2001
b91d92
From: Daniel Stenberg <daniel@haxx.se>
b91d92
Date: Thu, 3 Jan 2019 12:59:28 +0100
b91d92
Subject: [PATCH] ntlm: fix *_type3_message size check to avoid buffer overflow
b91d92
b91d92
Bug: https://curl.haxx.se/docs/CVE-2019-3822.html
b91d92
Reported-by: Wenxiang Qian
b91d92
CVE-2019-3822
b91d92
b91d92
Upstream-commit: 50c9484278c63b958655a717844f0721263939cc
b91d92
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b91d92
---
b91d92
 lib/vauth/ntlm.c | 11 +++++++----
b91d92
 1 file changed, 7 insertions(+), 4 deletions(-)
b91d92
b91d92
diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c
b91d92
index b614cda..a3a55d9 100644
b91d92
--- a/lib/vauth/ntlm.c
b91d92
+++ b/lib/vauth/ntlm.c
b91d92
@@ -777,11 +777,14 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
b91d92
   });
b91d92
 
b91d92
 #ifdef USE_NTRESPONSES
b91d92
-  if(size < (NTLM_BUFSIZE - ntresplen)) {
b91d92
-    DEBUGASSERT(size == (size_t)ntrespoff);
b91d92
-    memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
b91d92
-    size += ntresplen;
b91d92
+  /* ntresplen + size should not be risking an integer overflow here */
b91d92
+  if(ntresplen + size > sizeof(ntlmbuf)) {
b91d92
+    failf(data, "incoming NTLM message too big");
b91d92
+    return CURLE_OUT_OF_MEMORY;
b91d92
   }
b91d92
+  DEBUGASSERT(size == (size_t)ntrespoff);
b91d92
+  memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
b91d92
+  size += ntresplen;
b91d92
 
b91d92
   DEBUG_OUT({
b91d92
     fprintf(stderr, "\n   ntresp=");
b91d92
-- 
b91d92
2.17.2
b91d92