From 38c2a62d5a0a0b51c6d99b989caa3f953f1d53ab Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 26 May 2026 08:54:15 +0200 Subject: [PATCH] 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. --- src/base64.c | 3 +++ 1 file changed, 3 insertions(+) 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;