]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: base64 - Reformat flag handling in base64_decode_more().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 27 Aug 2019 18:46:42 +0000 (20:46 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:29 +0000 (10:02 +0300)
src/lib/base64.c

index 82029801597a0ac95e1e5a564165e2a4c15513e1..35e0a558a1244a68c233f160b8295307174d5a24 100644 (file)
@@ -468,10 +468,12 @@ int base64_decode_more(struct base64_decoder *dec,
 {
        const struct base64_scheme *b64 = dec->b64;
        const unsigned char *src_c = src;
-       bool expect_boundary = HAS_ALL_BITS(dec->flags,
-                                           BASE64_DECODE_FLAG_EXPECT_BOUNDARY);
-       bool no_whitespace = HAS_ALL_BITS(dec->flags,
-                                         BASE64_DECODE_FLAG_NO_WHITESPACE);
+       bool expect_boundary = HAS_ALL_BITS(
+               dec->flags, BASE64_DECODE_FLAG_EXPECT_BOUNDARY);
+       bool no_whitespace = HAS_ALL_BITS(
+               dec->flags, BASE64_DECODE_FLAG_NO_WHITESPACE);
+       bool no_padding = HAS_ALL_BITS(
+               dec->flags, BASE64_DECODE_FLAG_NO_PADDING);
        size_t src_pos, dst_avail;
        int ret = 1;
 
@@ -587,8 +589,7 @@ int base64_decode_more(struct base64_decoder *dec,
                /* try to parse the end (padding) of the base64 input */
                i_assert(src_pos < src_size);
 
-               if (HAS_ALL_BITS(dec->flags,
-                                BASE64_DECODE_FLAG_NO_PADDING)) {
+               if (no_padding) {
                        /* no padding allowed */
                        i_assert(!dec->seen_padding);
                        ret = -1;