Timo Sirainen [Fri, 29 Jun 2018 11:37:36 +0000 (14:37 +0300)]
director: Fix assert-crash when doveadm disconnects immediately after sending command
Any command that requires a ring sync should cause the doveadm connection to
wait until the ring is synced. However, if the disconnection happened early
enough the connection is deinitialized before the ring sync is finished.
Timo Sirainen [Fri, 7 Sep 2018 17:04:48 +0000 (20:04 +0300)]
doveadm: Make sure to stop running commands requiring synced ring when ring is no longer synced
A command could desync the ring, and no more commands should be run
afterwards.
This also fixes a bug where a command that desyncs the ring is supposed to
wait for the ring being synced before returning OK, but returns it
immediately instead.
Timo Sirainen [Fri, 17 Aug 2018 08:34:02 +0000 (11:34 +0300)]
lib: Mark signal waiting IO as "never wait alone"
This signal is being automatically moved to nested ioloops. It can't be the
only IO being waited, since there's no code that simply wants to wait for a
signal.
Timo Sirainen [Fri, 31 Aug 2018 11:57:13 +0000 (14:57 +0300)]
log: Move data stack frame allocation to parent function
This simplifies the next commit, which requires data stack nearly always
when logging. The data stack frames are cheap enough that we don't really
need to optimize for avoiding the cases when they're not needed.
Sergey Kitov [Mon, 26 Feb 2018 14:33:19 +0000 (16:33 +0200)]
lib: Add some event handling functions.
event_has_all_categories() - checks if given event contains all the
categories of an another event.
event_has_all_fields() - checks if given event contains all the fields
of an another event.
event_dup() - duplicates an event.
event_copy_categories_fields() - copies all categories and fields from
source to dest.
Stephan Bosch [Thu, 6 Sep 2018 13:22:30 +0000 (15:22 +0200)]
lib-http: client: peer: Notify all peers in a peer pool about a successful connection.
This allows peers for which the last connection attempt failed (which was not
the last pending attempt in the pool) to try again. This solves a problem that
could potentially cause a hang with multiple parallel clients creating serveral
new connections at once.
Stephan Bosch [Thu, 6 Sep 2018 01:11:18 +0000 (03:11 +0200)]
lib-http: client: peer: Always run http_client_queue_connection_failure() upon definitive connection failure.
The recorded peer->connecting flag was highly unreliable in a scenario involving
starting parallel connections. This way, the linked queues can update their
state accordingly. Also, this will not cause empty queues to initiate new
connection, because empty queues will do nothing after updating the connection
state.
This problem caused a client ioloop hang in high-load conditions.
Stephan Bosch [Thu, 6 Sep 2018 00:51:09 +0000 (02:51 +0200)]
lib-http: client: peer: Determine number of pending peers in http_client_peer_shared_connection_failure() itself.
Before, the number of pending peers was a parameter, but that was only for a
single peer pool. This is wrong, since the one peer can have many different
pools (depending on how many clients with incompatible configs share this
peer).
Timo Sirainen [Thu, 23 Aug 2018 11:33:59 +0000 (14:33 +0300)]
fts: Fix indexing mails with NULs in headers
After the first NUL all the rest of the string was converted to spaces.
This was broken already in the initial commit that attempted to fix this: 4d27f95c76bd008bb38f9c442567046da2b6ce14
Timo Sirainen [Fri, 17 Aug 2018 11:39:41 +0000 (14:39 +0300)]
lib-storage: Fix NUL handling in mail_get_first_header*(), mail_get_headers*()
These functions return NUL-terminated values, so they got truncated whenever
a header value contained a NUL. Fix this by converting NULs to unicode
replacement characters in the output.
Timo Sirainen [Wed, 25 Apr 2018 11:19:27 +0000 (14:19 +0300)]
lib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
As mentioned in previous commit, 0x80 isn't valid UTF-8 and we shouldn't
encourage using it. This implementation also can't be easily changed to
use unicode replacement character without larger changes to istream-nonuls.
Timo Sirainen [Wed, 25 Apr 2018 11:17:34 +0000 (14:17 +0300)]
lib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead
Using 0x80 produces invalid UTF-8 output, which we should avoid. Some places
in Dovecot code already requires that input is valid UTF-8, so it's also
safer and easier to use the unicode replacement character.
Timo Sirainen [Tue, 24 Apr 2018 15:01:03 +0000 (18:01 +0300)]
lib-mail: message_part_*_parse_from_header() - Replace NULs with 0x80
This avoids truncation of Content-*, Subject, Message-ID, In-Reply-To and
Date headers in IMAP ENVELOPE, BODY and BODYSTRUCTURE replies. Of course,
NULs in headers are violating RFCs already, so the previous behavior wasn't
really wrong either.
Timo Sirainen [Sat, 21 Apr 2018 13:07:21 +0000 (16:07 +0300)]
lib-fts: fts-tokenizer-address - Cleanup NUL handling in parent_data
The end result is anyway that the token will be truncated at the first NUL.
This change just makes the code a bit more understandable on where the
truncation will happen.
Timo Sirainen [Sat, 21 Apr 2018 13:11:48 +0000 (16:11 +0300)]
lib: Add str_append_max()
It's otherwise the same as str_append_n(), except it takes const char* as
input instead of const void*. This, as well as its name, should make it
less likely to be used wrong when the input may legitimately have NULs.
The unit test is changed from str_append_n() to str_append_max(), because
str_append_n() will be deprecated.
It's not valid to have "\<CR>" or "\<LF>", so the old behavior isn't really
wrong either. However, rfc822_parse_quoted_string() callers are more likely
to expect that the output won't contain any [CR]LF so this new behavior is
a bit better.
Timo Sirainen [Sat, 21 Apr 2018 09:47:22 +0000 (12:47 +0300)]
lib-mail: Change rfc822_parse_content_param() API to allow NULs in value
This was the only function in rfc822-parser.h that wasn't NUL-safe.
This won't fix anything, but it makes the rfc822-parser.h API fully
consistent with the NUL handling.
Normally rfc2231_parse() should be called instead of calling
rfc822_parse_content_param() directly, so this shouldn't break any plugins.
Timo Sirainen [Sat, 21 Apr 2018 13:03:42 +0000 (16:03 +0300)]
login-common: Consistently truncate client SASL input at first NUL
The input is supposed to be base64-encoded, so there's no need to support
actual NUL characters. The previous code truncated at NULs, but could have
kept appending more data to the value. This could have produced somewhat
random results.
Timo Sirainen [Sat, 21 Apr 2018 12:58:15 +0000 (15:58 +0300)]
lib-master, util: Consistently truncate tabescaped input at the first NUL
The NULs are supposed to come tab-escaped, so there's no need to support
actual NUL characters. The previous code truncated at NULs, but could
have kept appending more data to the value. This could have produced
somewhat random results.
Timo Sirainen [Sat, 21 Apr 2018 12:53:42 +0000 (15:53 +0300)]
config: Consistently truncate value at the first NUL in value input file
When value contained "<file", the file was added as a value. The setting
values don't currently support NULs, so the value gets truncated at the
first NUL. However, the previous code could have appended more data to
the value. This could have produced somewhat confusing results.
Timo Sirainen [Sat, 21 Apr 2018 12:50:08 +0000 (15:50 +0300)]
dict-fs/memcached-ascii/redis: Consistently truncate value at NULs
The dict API currently doesn't support NULs in values, so they have to be
truncated. However, previously they were truncated at NULs, but more data
may have still been appended to the value. This could have produced
somewhat random results.