From: Timo Sirainen Date: Sat, 15 Dec 2018 14:32:22 +0000 (+0200) Subject: lib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't underflow X-Git-Tag: 2.3.5~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cc1c3fb1e40e408d33692ec6ccbd4978751f3949;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't underflow --- diff --git a/src/lib-mail/ostream-dot.c b/src/lib-mail/ostream-dot.c index 6827cbdc01..3909801cae 100644 --- a/src/lib-mail/ostream-dot.c +++ b/src/lib-mail/ostream-dot.c @@ -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; }