Skip to content

Commit

Permalink
lib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't un…
Browse files Browse the repository at this point in the history
…derflow
  • Loading branch information
sirainen committed Feb 15, 2019
1 parent 3df4e47 commit cc1c3fb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib-mail/ostream-dot.c
Expand Up @@ -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;
}
Expand All @@ -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++;
Expand All @@ -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;
}
Expand Down

0 comments on commit cc1c3fb

Please sign in to comment.