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.
This commit is contained in:
Willy Tarreau 2026-05-26 08:54:15 +02:00
parent 6eefa71ac0
commit 38c2a62d5a

View file

@ -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;