From cb13e555b2f95ffa349fabe2e6c45f87264c2e3f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 11 Jan 2023 01:23:03 +0200 Subject: [PATCH] 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) --- src/replication/aggregator/replicator-connection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') { -- 2.47.3