]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: base64 - Change MAX_BASE64_DECODED_SIZE() to be more exact
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 28 May 2019 10:35:11 +0000 (13:35 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:22 +0000 (10:02 +0300)
If the input has only full base64 blocks (is divisible by 4), there's no
need to add the extra +3.

src/lib/base64.h

index 0576f62e67bfdc98bf19dd7a0d1cc5183ec21559..b497926f7fd7d0b335fd93b441e3de2a26afd9b1 100644 (file)
@@ -28,5 +28,5 @@ bool base64_is_valid_char(char c);
        ((((size) + 2) / 3) * 4)
 /* max. buffer size required for base64_decode() */
 #define MAX_BASE64_DECODED_SIZE(size) \
-       ((size) / 4 * 3 + 3)
+       (((size) + 3) / 4 * 3)
 #endif