]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
aggregator: Fix assert-crash when output to replicator starts queuing
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 10 Jan 2023 23:23:03 +0000 (01:23 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 1 Feb 2023 15:32:04 +0000 (15:32 +0000)
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

index 44b37b9239433b85b75ff74b8ca0e8afbb631607..9fab8f02e9134e313f2aba4475720bb7236baf72 100644 (file)
@@ -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') {