From c1366571b609407cf0d4d9f4a2769d29e1313151 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Mar 2018 15:15:14 +0100 Subject: vauth/cleartext: fix integer overflow check Make the integer overflow check not rely on the undefined behavior that a size_t wraps around on overflow. Detected by lgtm.com Closes #2408 --- lib/curl_setup.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/curl_setup.h') diff --git a/lib/curl_setup.h b/lib/curl_setup.h index f128696e9..e4503c64c 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -447,6 +447,15 @@ # 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 + /* * Arg 2 type for gethostname in case it hasn't been defined in config file. */ -- cgit v1.2.3