From: Daniel Stenberg Date: Mon, 13 Aug 2018 08:35:52 +0000 (+0200) Subject: Curl_ntlm_core_mk_nt_hash: return error on too long password X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fcurl.git;a=commitdiff_plain;h=ba96fa38870e04e258260c48722421692dcc8482 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 Backported patch details:- Link: https://github.com/curl/curl/commit/57d299a499155d4b327e341c6024e293b0418243.patch Change-Id: I9a2cdc3aca86291721b508dae173dca30b6126f9 Signed-off-by: Nishant Chaprana --- diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index 72eda34..b69c293 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;