← Commit list

c5de083bcc

Daniel Stenberg
Daniel Stenberg
2025-10-30
SUCCESS Duration: 148s

Subject

base64: make base64_encode() error on too long input

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/curlx/base64.c+4 -4
@@ -184,10 +184,10 @@ static CURLcode base64_encode(const char *table64,
if(!insize)
return CURLE_OK;
-#if SIZEOF_SIZE_T == 4
- if(insize > UINT_MAX/4)
- return CURLE_OUT_OF_MEMORY;
-#endif
+ /* safety precaution */
+ DEBUGASSERT(insize <= CURL_MAX_BASE64_INPUT);
+ if(insize > CURL_MAX_BASE64_INPUT)
+ return CURLE_TOO_LARGE;
base64data = output = malloc((insize + 2) / 3 * 4 + 1);
if(!output)
lib/curlx/base64.h+4 -0
@@ -33,4 +33,8 @@ CURLcode curlx_base64_decode(const char *src,
extern const char Curl_base64encdec[];
+/* maximum input length acceptable to base64 encode, here to catch and prevent
+ mistakes */
+#define CURL_MAX_BASE64_INPUT 16000000
+
#endif /* HEADER_CURL_BASE64_H */