]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: base64 - Fix dest buffer assertion in base64_decode_more().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 4 Sep 2019 10:33:08 +0000 (12:33 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:38 +0000 (10:02 +0300)
The assertion is supposed to trigger when the encoder hits the buffer size limit
unexpectedly (src_pos_r==NULL means that all should be encoded at once). It
triggered erroneously when the destination buffer had the exact size needed
for the encoded data.

src/lib/base64.c

index 60ceb132f95c71d1f95f97cf962823953cdb52dd..fb6cd635e62d265d8fd5c0aebbbff1232f7f4474 100644 (file)
@@ -591,8 +591,10 @@ int base64_decode_more(struct base64_decoder *dec,
                        i_unreached();
                }
                if (dst_avail == 0) {
-                       i_assert(src_pos_r != NULL);
-                       *src_pos_r = src_pos + 1;
+                       if (src_pos_r != NULL)
+                               *src_pos_r = src_pos + 1;
+                       else
+                               i_assert(src_pos + 1 == src_size);
                        return 1;
                }
        }