Timo Sirainen [Fri, 10 Sep 2021 16:00:09 +0000 (19:00 +0300)]
lib: ENUM_NEGATE() - Disable runtime sizeof() check with STATIC_CHECKER
This is to avoid "Dangerous variable-length array (VLA) declaration"
errors with clang 12 scan-build, which happen because scan-build keeps
thinking that the enums can become larger than 2147483647.
Aki Tuomi [Wed, 8 Sep 2021 06:53:12 +0000 (09:53 +0300)]
doveadm: doveadm-stats - Allocate field_types
field_types was function local variable that got used outside
of function. Change to use datastack allocation instead to
keep it valid after leaving function.
Timo Sirainen [Thu, 19 Aug 2021 10:50:04 +0000 (12:50 +0200)]
lib-storage: Make sure header parsing is deinitialized after failures
This should fix all the possible reasons for:
Panic: file index-mail-headers.c: line 198 (index_mail_parse_header_init): assertion failed: (!mail->data.header_parser_initialized)
Timo Sirainen [Thu, 19 Aug 2021 10:32:45 +0000 (12:32 +0200)]
lib-storage: Fix potential assert-crash if filter-stream fails
If filter-stream isn't read until header (because the parent istream fails),
the header parsing isn't deinitialized. If after the failure the headers are
attempted to be parsed again, there's an assert-crash. Make sure this won't
happen by finishing the filter-istream read, and if that fails then reset the
header parsing anyway.
Destroying the filter_stream may also change the parent istream offset to
change, so this commit adds an extra seek to beginning of the istream when
beginning to parse the mail headers.
Fixes:
Panic: file index-mail-headers.c: line 198 (index_mail_parse_header_init): assertion failed: (!mail->data.header_parser_initialized)
Timo Sirainen [Wed, 18 Aug 2021 12:04:53 +0000 (14:04 +0200)]
lib-storage: Fix assert-crash in special partial mail parsing failures
This happened for example if:
- mail_precache() started parsing mail
- header was parsed, but mail body parsing failed due to mail size mismatch
- vsize parsing doesn't restart header parsing, because header size is already known
- body parsing assert-crashes because there is no messsage parser initialized
Timo Sirainen [Tue, 24 Aug 2021 20:58:59 +0000 (22:58 +0200)]
lib-test: Fix race when subprocess immediately receives signal
Signal could be received before test_subprocess_is_child=1 is set, causing
the subprocess's signal handler to also attempt to cleanup other
subprocesses.
This was causing http-test-client-errors unit tests to fail somewhat
randomly, especially when running them only with 1 CPU.
Stephan Bosch [Tue, 13 Apr 2021 16:25:06 +0000 (18:25 +0200)]
lib-smtp: smtp-server-cmd-rcpt - Fix assert crash occurring for pipelined MAIL RCPT MAIL sequence.
The assertion is wrong in that it assumes that no MAIL commands can be pending
once RCPT command is next to reply. The RCPT command does not block the
pipeline, so that a subsequent MAIL command can also be pending (but will almost
never succeed).
Reading assert-crashed if the header was read only partially. Either
because the file really was truncated or because parent stream already
had fewer bytes buffered.
Siavash Tavakoli [Fri, 25 Jun 2021 13:11:52 +0000 (14:11 +0100)]
dict: Add caching mechanism for initializing dicts
Add a pool for dict instances. Each dict is refcounted and given a grace period
of 30 seconds for deletion. If refcount drops to 0 and no new dict
operation uses the instance in that period, it will be freed. A maximum
of 10 dicts are kept in the cache.
Timo Sirainen [Tue, 27 Apr 2021 23:01:14 +0000 (02:01 +0300)]
lib-index: Fix "Extension introduction for unknown id" errors after map is generated
This happens when:
* View is opened
* Messages are expunged
* View is synced with NOEXPUNGES flag
* A new extension is introduced
* Index is rotated at least twice
* View is again synced with NOEXPUNGES flag
* More changes are done to index with the new extension
* Once more view is synced with NOEXPUNGES flag
The last sync will see changes with the new extension ID, but the view's map
doesn't know its ID.
virtual: Expunge old emails if backend box guid changed
This introduces a new extensible "ext2" header to make it easier to add new
fields in the future. It also allows keeping backwards/forwards
compatibility with the old code, so the virtual index isn't rebuilt on
upgrades or downgrades.
Timo Sirainen [Tue, 3 Aug 2021 16:47:54 +0000 (19:47 +0300)]
imap, pop3: Prevent reading ssl_ca setting into memory
Especially with imap there can be a lot of processes and a large ssl_ca
could be wasting a lot of memory. This was already the old behavior before
removing ssl_* settings from lib-storage.