From: Timo Sirainen Date: Tue, 10 Jan 2023 23:23:03 +0000 (+0200) Subject: aggregator: Fix assert-crash when output to replicator starts queuing X-Git-Tag: 2.4.0~3012 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb13e555b2f95ffa349fabe2e6c45f87264c2e3f;p=thirdparty%2Fdovecot%2Fcore.git aggregator: Fix assert-crash when output to replicator starts queuing If the output was less than IO_BLOCK_SIZE (as it usually would be), the code just skipped over the whole buffered output and was confused that it didn't find LF. Fixed by skipping over all but the last byte in the buffer, which should be the LF. Fixes: Panic: file replicator-connection.c: line 99 (replicator_send_buf): assertion failed: (len < buf->used) --- diff --git a/src/replication/aggregator/replicator-connection.c b/src/replication/aggregator/replicator-connection.c index 44b37b9239..9fab8f02e9 100644 --- a/src/replication/aggregator/replicator-connection.c +++ b/src/replication/aggregator/replicator-connection.c @@ -93,8 +93,8 @@ replicator_send_buf(struct replicator_connection *conn, buffer_t *buf) /* try to send about IO_BLOCK_SIZE amount of data, but only full lines */ - if (len > buf->used) - len = buf->used; + if (len >= buf->used) + len = buf->used - 1; for (;; len++) { i_assert(len < buf->used); /* there is always LF */ if (data[len] == '\n') {