From 1e4843fda3d40bca3df4479fc3785432dd00e260 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 12 Jun 2023 20:27:51 +0200 Subject: [PATCH] Fix 'CVE-2018-14618' Merge: curl/curl@8c7b3737d29ed5c0575bf5 --- r5dev/thirdparty/curl/curl_ntlm_core.c | 11 ++++------- r5dev/thirdparty/curl/curl_setup.h | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/r5dev/thirdparty/curl/curl_ntlm_core.c b/r5dev/thirdparty/curl/curl_ntlm_core.c index d5631a72..0ae665a2 100644 --- a/r5dev/thirdparty/curl/curl_ntlm_core.c +++ b/r5dev/thirdparty/curl/curl_ntlm_core.c @@ -535,8 +535,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 = malloc(len * 2); + 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; @@ -618,12 +621,6 @@ CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, return CURLE_OK; } -#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4) -#define SIZE_T_MAX 18446744073709551615U -#else -#define SIZE_T_MAX 4294967295U -#endif - /* This creates the NTLMv2 hash by using NTLM hash as the key and Unicode * (uppercase UserName + Domain) as the data */ diff --git a/r5dev/thirdparty/curl/curl_setup.h b/r5dev/thirdparty/curl/curl_setup.h index 9d99f139..0f2d6358 100644 --- a/r5dev/thirdparty/curl/curl_setup.h +++ b/r5dev/thirdparty/curl/curl_setup.h @@ -751,4 +751,23 @@ endings either CRLF or LF so 't' is appropriate. # endif # endif + +#ifndef SIZE_T_MAX +/* some limits.h headers have this defined, some don't */ +#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4) +#define SIZE_T_MAX 18446744073709551615U +#else +#define SIZE_T_MAX 4294967295U +#endif +#endif + +#ifndef SSIZE_T_MAX +/* some limits.h headers have this defined, some don't */ +#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4) +#define SSIZE_T_MAX 9223372036854775807 +#else +#define SSIZE_T_MAX 2147483647 +#endif +#endif + #endif /* HEADER_CURL_SETUP_H */