]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't underflow
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 15 Dec 2018 14:32:22 +0000 (16:32 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 15 Feb 2019 12:47:37 +0000 (12:47 +0000)
src/lib-mail/ostream-dot.c

index 6827cbdc01250b008453819d31f9ad77fad48197..3909801caea0b44ceb13e0fd531b96fbe1faa113 100644 (file)
@@ -167,6 +167,7 @@ o_stream_dot_sendv(struct ostream_private *stream,
                                        iovn.iov_len = chunk;
                                        array_append(&iov_arr, &iovn, 1);
                                        data = p;
+                                       i_assert(max_bytes >= chunk);
                                        max_bytes -= chunk;
                                        sent += chunk;
                                }
@@ -175,6 +176,7 @@ o_stream_dot_sendv(struct ostream_private *stream,
                                iovn.iov_base = (add == '\r' ? "\r\n" : "..");
                                iovn.iov_len = 2;
                                array_append(&iov_arr, &iovn, 1);
+                               i_assert(max_bytes >= 2);
                                max_bytes -= 2;
                                added++;
                                sent++;
@@ -189,6 +191,7 @@ o_stream_dot_sendv(struct ostream_private *stream,
                        iovn.iov_base = data;
                        iovn.iov_len = chunk;
                        array_append(&iov_arr, &iovn, 1);
+                       i_assert(max_bytes >= chunk);
                        max_bytes -= chunk;
                        sent += chunk;
                }