From: Stefan Eissing Date: Thu, 9 Oct 2025 09:42:43 +0000 (+0200) Subject: memdup0: handle edge case X-Git-Tag: rc-8_17_0-3~241 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e2c582d6c4d676d34c56406301886784021e263;p=thirdparty%2Fcurl.git memdup0: handle edge case When length is already SIZE_MAX, fail without allocating. Reported-by: Joshua Rogers Closes #18966 --- diff --git a/lib/strdup.c b/lib/strdup.c index 66fd7c60eb..3339e909ee 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -111,7 +111,7 @@ void *Curl_memdup(const void *src, size_t length) ***************************************************************************/ void *Curl_memdup0(const char *src, size_t length) { - char *buf = malloc(length + 1); + char *buf = (length < SIZE_MAX) ? malloc(length + 1) : NULL; if(!buf) return NULL; if(length) {