From: Willy Tarreau Date: Tue, 26 May 2026 06:54:15 +0000 (+0200) Subject: BUG/MINOR: base64: return empty string for empty input in base64dec() X-Git-Tag: v3.4-dev14~31 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=997c99df9c7957071d0e63d0c98f2f07ef013580;p=thirdparty%2Fhaproxy.git BUG/MINOR: base64: return empty string for empty input in base64dec() Right now no special case is made of size zero and the parser assumes that it can read the last two chars, which do not exist in this case. Let's check for this empty string situation and return zero (empty) as well. This should be backported to all versions. --- diff --git a/src/base64.c b/src/base64.c index 0601bf673..57cb7d06a 100644 --- a/src/base64.c +++ b/src/base64.c @@ -125,6 +125,9 @@ int base64dec(const char *in, size_t ilen, char *out, size_t olen) { signed char b; int convlen = 0, i = 0, pad = 0; + if (!ilen) + return 0; + if (ilen % 4) return -1;