]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: base64: return empty string for empty input in base64dec()
authorWilly Tarreau <w@1wt.eu>
Tue, 26 May 2026 06:54:15 +0000 (08:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 May 2026 11:13:24 +0000 (13:13 +0200)
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

index 0601bf673e1984e497492c251346f6153d088ee0..57cb7d06a36fbdbe5560689bf85ef05ebde998ba 100644 (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;