aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-08-13 10:35:52 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-09-03 07:42:37 +0200
commit57d299a499155d4b327e341c6024e293b0418243 (patch)
tree8eabfe89955a2dc43cbc6b46f0a9778b6bcc9c3d /lib
parent19ebc282172ff204648f350c6e716197d5b4d221 (diff)
Curl_ntlm_core_mk_nt_hash: return error on too long password
... since it would cause an integer overflow if longer than (max size_t / 2). This is CVE-2018-14618 Bug: https://curl.haxx.se/docs/CVE-2018-14618.html Closes #2756 Reported-by: Zhaoyang Wu
Diffstat (limited to 'lib')
-rw-r--r--lib/curl_ntlm_core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
index e27cab353..922e85a92 100644
--- a/lib/curl_ntlm_core.c
+++ b/lib/curl_ntlm_core.c
@@ -557,8 +557,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
unsigned char *ntbuffer /* 21 bytes */)
{
size_t len = strlen(password);
- unsigned char *pw = len ? malloc(len * 2) : strdup("");
+ unsigned char *pw;
CURLcode result;
+ if(len > SIZE_T_MAX/2) /* avoid integer overflow */
+ return CURLE_OUT_OF_MEMORY;
+ pw = len ? malloc(len * 2) : strdup("");
if(!pw)
return CURLE_OUT_OF_MEMORY;