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.
Timo Sirainen [Fri, 31 Aug 2018 10:04:53 +0000 (13:04 +0300)]
lib: Fix matching parent categories in event filter
So far this hasn't caused problems, because parent events had been using
parent categories. However, if the parent category wasn't used by an event
or its parents, an event filter wouldn't have matched it.
Phil Carmody [Wed, 29 Aug 2018 12:28:31 +0000 (15:28 +0300)]
lib/array - give arrays the non-freeing deinit that strings and buffers have
Buffers provide the ability to free the control block but preserve and
return the previously controlled data to the caller: buffer_free_without_data().
As wrapped buffers, strings also have this functionality: str_free_without_data().
(They have to do that, as their buffer implementation is encapsulated away
out of sight to the str.h user.)
Arrays, also wrapped buffers, are missing this capability under the 'array'
name, you have to use the buffer function call, which involves diving into
the guts of the array implementation (because arrays do not hide their
implementation like strings do), and also sacrifices array's type safety.
With this inline helper, it should be simple, obvious, clean and safe.
Phil Carmody [Tue, 19 Jun 2018 12:30:36 +0000 (15:30 +0300)]
m4/dovecot.m4: rename valgrind output file to hide it from certain tests
Some lib-http tests use readdir() to create test cases, and sometimes
object to the contents of test.out.$$. However, as lib-http is also
sensitive to certain characters in the filenames of the files it uses,
we can hide the valgrind output by chosing its filename to exclude it
from the lib_http tests. Non-initial '~' is not known to cause any issues
for either the shell or any known operating system, so is the safest of
lib-http's 'dodgy' characters to use as the separator.
Phil Carmody [Tue, 19 Jun 2018 10:29:46 +0000 (13:29 +0300)]
lib-http: increase pool sizes in tests
Pool growth messages spam the test output, just dive in with a slightly
larger default to shut them up. Only affects these individual tests,
not any other users of the library.
Phil Carmody [Thu, 14 Jun 2018 05:51:37 +0000 (08:51 +0300)]
lib-http: harden payload tests against dodgy filenames
Tests use files from readdir() as input, but do no sanitation of the
names, and therefore things like editor temp files can cause havoc
with the HTTP request parser.
The solution is to trap dodgy characters in the filenames, and ignore
those files. Initially, trap HTTP's "unsafe" and "reserved" characters.
Timo Sirainen [Wed, 29 Aug 2018 19:09:57 +0000 (22:09 +0300)]
lib-master, master: Initialize stats-client via environment variables
That way it's initialized before settings are read, and it can catch events
earlier. It also doesn't require all services to read settings if they
otherwise don't need them.
Phil Carmody [Wed, 29 Aug 2018 12:15:30 +0000 (15:15 +0300)]
lib-dns - struct member cleanup in dns_lookup
The index was never used anyway. Now we're using an alloconly pool,
there's no need for the dns_lookup to keep a freeable pointer to the
fields also int result.
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 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.
Stephan Bosch [Wed, 15 Aug 2018 22:42:50 +0000 (00:42 +0200)]
lib-smtp: client: Fix transaction state transition for the DATA command.
It progressed to the DATA state too early. By the looks of things, this only
affected the correctness of error and debug messages. It does not affect the
transaction itself.
The delay (previously 100ms, now 1s) is intended to delay our exit enough so
that the child processes have a chance to receive & handle the SIGQUITs we
just sent. If we don't wait long enough, it is possible that we'll get
restarted before our children had the chance to stop listening on their
sockets and we'll hit "address already in use" type errors.
Increasing the delay does not fix the issue, but it masks it better.
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.
Stephan Bosch [Mon, 13 Aug 2018 17:23:31 +0000 (19:23 +0200)]
lib-http: test-http-client-errors: Make "peer reuse failure" test reliable.
It was highly timing-sensitive, since it required a particular error status to
be returned. Sometimes, it would yield a different error based on a
slightly different order of events, making the test fail. Such failures aren't
relevant though, since this regression test is about triggering a segfault that
used to occur.
Timo Sirainen [Mon, 6 Aug 2018 09:39:25 +0000 (12:39 +0300)]
imap: Fix command ambiguity checking with special plugins
If the tagged line is already sent, that command can't result in ambiguity
anymore.
A cleaner fix would be to add a new _WAIT_SYNC_OUTPUT state, but that
requires all the existing code to understand that new state correctly, so it
has a higher chance of breaking something. So at least for now don't add it.