aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-01-03 12:59:28 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-02-04 08:22:32 +0100
commit50c9484278c63b958655a717844f0721263939cc (patch)
treeb13b3a6709f727f8d38df6107bacfc5bf0efa6b0 /lib
parentb780b30d1377adb10bbe774835f49e9b237fb9bb (diff)
ntlm: fix *_type3_message size check to avoid buffer overflow
Bug: https://curl.haxx.se/docs/CVE-2019-3822.html Reported-by: Wenxiang Qian CVE-2019-3822
Diffstat (limited to 'lib')
-rw-r--r--lib/vauth/ntlm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c
index 0ad4d972e..6a8fc5ab3 100644
--- a/lib/vauth/ntlm.c
+++ b/lib/vauth/ntlm.c
@@ -779,11 +779,14 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
});
#ifdef USE_NTRESPONSES
- if(size < (NTLM_BUFSIZE - ntresplen)) {
- DEBUGASSERT(size == (size_t)ntrespoff);
- memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
- size += ntresplen;
+ /* ntresplen + size should not be risking an integer overflow here */
+ if(ntresplen + size > sizeof(ntlmbuf)) {
+ failf(data, "incoming NTLM message too big");
+ return CURLE_OUT_OF_MEMORY;
}
+ DEBUGASSERT(size == (size_t)ntrespoff);
+ memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
+ size += ntresplen;
DEBUG_OUT({
fprintf(stderr, "\n ntresp=");