]> granicus.if.org Git - curl/commitdiff
Curl_ntlm_core_mk_nt_hash: return error on too long password
authorDaniel Stenberg <daniel@haxx.se>
Mon, 13 Aug 2018 08:35:52 +0000 (10:35 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 3 Sep 2018 05:42:37 +0000 (07:42 +0200)
... 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
lib/curl_ntlm_core.c

index e27cab353c9d39ade85d48c9f655c19d8a2c4ac6..922e85a9269519ac46ec3c3bbcfb872c07e6754c 100644 (file)
@@ -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;