Timo Sirainen [Tue, 22 Oct 2019 16:59:43 +0000 (19:59 +0300)]
lib-storage: Copy vsize record even when destination mailbox doesn't have it
It's almost guaranteed that if the source mailbox has vsize then we want the
destination mailbox to also have it. This condition now happens mainly when
copying mails to a newly created mailbox where the vsize lookups haven't
occurred yet. It's better to do this immediately to avoid unnecessarily slow
lookups later on.
Timo Sirainen [Sun, 20 Oct 2019 10:48:22 +0000 (13:48 +0300)]
dsync: Fix potential hang when initializing remote dsync
The initial dsync handshake TCP packet could be in the same packet as the
previous doveadm command. This started happening more often with the
recent multiplex ostream corking changes in f284865285ae461b293c713e03277cfbb6973eca
Stephan Bosch [Sun, 13 Oct 2019 09:01:53 +0000 (11:01 +0200)]
lib: istream - Fix calling i_stream_nonseekable_try_seek() without intermittent reads.
Calling i_stream_nonseekable_try_seek() sets stream->high_pos when seeking back
within buffer. Once i_stream_read_memarea() is called, the pos is set to
high_pos and the high pos is cleared. However, when no read is performed in the
mean time, another call to i_stream_nonseekable_try_seek() would overwrite the
high_pos value with pos, causing the true value to get lost, leading to all
kinds of issues. This is fixed by checking whether high_pos is already set and
not touching it when it is (first value is the only valid one).
One issue this caused is that the mbox storage would no longer work with
compression, triggering `unexpected EOF' errors.
Timo Sirainen [Tue, 8 Oct 2019 13:14:15 +0000 (16:14 +0300)]
*-login: Fix potential hangs with SSL connections
1) Multi-step SASL authentication could hang when login process waits for
response from a client, but it has already pipelined it together with the
AUTH/AUTHENTICATE command.
2) After failed authentication commands could start hanging.
Timo Sirainen [Sat, 5 Oct 2019 12:46:47 +0000 (15:46 +0300)]
lib-index: Fix checking if log file can be rotated
This fixes a bug caused by 883a3022992d0f832f0aff21572caeb7c63b7668 where
dovecot.index.log file wasn't rotated as often as it was supposed to be. It
also could have caused dovecot.index to be rewritten much more often than
it was supposed to be.
The buggy commit was correct that the tail_offset wasn't updated previously
to the dovecot.index.log file after changes. However, I didn't realize that
the tail_offset was internally still updated and required by this rotation
check to work correctly.
The fix works by relaxing the tail_offset==head_offset requirement for
rotation. It's enough that all the changes are synced, which can be checked
from mail_index_sync_ctx.fully_synced. Any changes after tail_offset are
then supposed to be external transactions, which aren't synced anyway, so
rotation is allowed.
Stephan Bosch [Sun, 4 Nov 2018 18:00:47 +0000 (19:00 +0100)]
lib-smtp: smtp-address - Implement workarounds for parsing addresses with a bad localpart.
Always parse it as normal when it starts with `<' or `"'. The workaround
consists of parsing the address by splitting it on the last `@'. The address is
accepted when the resulting localpart and domain can be used to compose a valid
address. This workaround is now shared with username-to-address parsing, which
existed before.
Stephan Bosch [Sun, 4 Nov 2018 18:09:41 +0000 (19:09 +0100)]
lib-smtp: smtp-address - Allow parsing address from username that contains space, double quote or backslash.
Not allowing double quote and backslash was a bug, while space was explicitly
disallowed. However, these characters can be used in an RFC 5321 address when
inside a quoted string, so there is no reason to disallow those.
Aki Tuomi [Thu, 26 Sep 2019 09:34:18 +0000 (12:34 +0300)]
login-common: Retrieve error from ssl context if handshake fails
Fixes
imap-login: Error: proxy: Failed to start SSL handshake to 127.0.0.2:43143: (null)
and
imap-login: Error: Failed to initialize SSL server context: Can't load SSL certificate: error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
Fatal: master: service(imap-login): child 14764 killed with signal 11 (core dumped)
Timo Sirainen [Wed, 11 Sep 2019 08:11:57 +0000 (11:11 +0300)]
lib: i_stream_get_data() - Mark invalid buffer code path unlikely
This really isn't expected to happen, so marking it unlikely optimizes
slightly callers that cause i_stream_get_data() to be called a huge number
of times.
Calling it may change the stream's buffer and free the old buffer. However,
some istreams didn't change the buffer if i_stream_read_memarea() returned
-2. The old buffer was kept referenced, which could have caused the istream
to read garbage or crash due to accessing freed memory.
Timo Sirainen [Thu, 5 Sep 2019 08:57:20 +0000 (11:57 +0300)]
lib, lib-master: Remove event.call_free
Just call the EVENT_CALLBACK_TYPE_FREE always. Having this flag isn't
really going to affect the performance, and it might be useful in the
future to work this way.
Only the unit test was relying on call_free to be different from
id_sent_to_stats. This commit changes the unit test to check for the
END strings where necessary.