Timo Sirainen [Wed, 28 May 2014 01:20:58 +0000 (04:20 +0300)]
lib-storage: "Message has no NUL characters" flag was being set wrong to cache file.
Only the first MIME part was checked for its existence.
When this flag was wrong, IMAP FETCH may have returned NUL characters
instead of converting them to 0x80 character. This apparently caused Outlook
to hang.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
auth: checkpassword callback callback type bike-shedding
This change doesn't change the compiler's (gcc) view on the correctness of
the code. It moves sparse's attention of where the potential issues are
though. Sparse used to complain about dodgy function pointer conversions on
both the way out (passing the callback function pointer), and on the way in
(entering the callback). Making the callback not lie about what it receives
gets rid of the way in warnings, but adds warnings as we pass the new
function pointer out. However, it already complains about that call anyway.
So it complains about 6 things in 3 functions rather than 6 things in 6
functions.
Of dubious worth, but it at least reduces the number of lines you need to
inspect to verify correctness.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
imap: use human-readable helper macro in remote_ip_is_usable
More readable, but helpfully shuts up sparse which complained about some
constants being long.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
imap: cmd_getmetadata_stream_continue returns bool, not int
The behaviour is unchanged, but we shouldn't pretend that -1 is different
from TRUE in a boolean context. Its only caller only cares about whether
it's 0 or not.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
indexer: fix indexer_queue_cancel_all behaviour
-1 is TRUE. Presumably -1 was intended to be passed to the callbacks via
indexer_queue_request_status_int(), not 100.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
auth: master-connection - bail on malformed list
If master is not communicating to us in a syntax we understand, just ask for
it to be unplugged. This changes the behaviour in this error case.
Previously, we returned -1, which is TRUE when converted to a boolean, and
thus this changes the error semantics, and may be horribly wrong. However,
the i_error()s in auth_master_input_line follow the same pattern.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
auth: set_credentials callback being passed an enum, not a bool
This changes the behaviour, as the error case is now mapped onto FALSE.
All non-zero values of course get squashed into true. Found by sparse.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
lib-otp: cast to the correct type of function pointer
sparse complains about the result of the F() cast being the wrong type
for the initialisation, which is true. So just cast to the right type
in the first place.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
imap: fix missing-command check
It's impossible for the command's pointer to be NULL at this point.
Previously, the command_find() would have returned NULL, but this check
presumably short-circuits that search in the trivial case, so has some
real use.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
auth: sparse static cleanup, and some const cleanup
All the consts that are added to pointers represent deep const semantics.
There are other shallow consts that I've not added, as sometimes it's
better to not be const than have something you rely on change when you
think it won't.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
lib: pair VA_COPY with va_end
A va_copy creates a initialised va_list, as if a va_start had been done on it.
Therefore, pedantically, a va_end should also be done on it. On most platforms
this is a no-op, and for those where it isn't, the pairing is important.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
fts: parser-html - parser can fail on attributes='with values in single quotes'
If that value were to contain an odd number of double quotes, then the
HTML_STATE_TAG_(D)QUOTED state would be entered and not exited.
The two quoting types behave basically the same, so just add two new cases
and duplicate the state transition code.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
fts: parser-html - parse_tag_name returns wrong value for comments
This function returns 1 more than the number of additional
characters to be swallowed up by the state transition.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
fts: parser-html - parse_tag_name really does return an integer not a bool
It seems to return 1 more than the number of additional characters
(after '<') are swallowed up by the state change, not a bool. This
would imply that '3' is wrong.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
lib-storage: functions returning bool actually return ints
Their return values are compared as if they are at least tri-state
(-ve, 0, +ve), so really aren't bools at all.
Note - this should cause the code to change in behaviour, and thus might
introduce regressions as previously all non-zeroes would have been mapped
to 1.
Phil Carmody [Tue, 27 May 2014 18:17:34 +0000 (21:17 +0300)]
lib-storage: context's dotlock_last_stale really is bool
It's only ever read as if it's a bool, so it really is a bool. Fix a write
treating it as an int.
Timo Sirainen [Thu, 22 May 2014 01:12:05 +0000 (18:12 -0700)]
lib-storage: Added mailbox_list_index_very_dirty_syncs setting.
This setting assumes that the mailbox list index is up to date and uses it
without stat()ing backend mailbox files/dirs. (As a possible future TODO it
might be useful to still do the stat()ing, but only rarely.)
Timo Sirainen [Thu, 15 May 2014 20:41:55 +0000 (23:41 +0300)]
lib-imap: Use case-insensitive comparisons everywhere for imap_id_send setting parsing.
"os" and "os-version" were case-sensitive while others were not.
Patch by Apple.
Timo Sirainen [Mon, 12 May 2014 09:18:46 +0000 (12:18 +0300)]
acl: Empty negative rights list should be the same as NULL negative rights list.
There may be other places where this should be fixed, but this at least
fixes errors with dsync where "-user" entry without any rights was attempted
to be synced in dovecot-acl (although such entry shouldn't really have
existed in the first place).
Timo Sirainen [Sun, 11 May 2014 18:08:51 +0000 (21:08 +0300)]
lib-mail: message_header_encode_[bq]() now explicitly takes the first line length parameter.
So this change partially reverts the previous change, because
message_header_encode() was actually internally relying on this behavior.
The explicit parameter makes it clearer.
Timo Sirainen [Sun, 11 May 2014 15:28:03 +0000 (18:28 +0300)]
lib-mail: message_header_encode() no longer tries to lookup the first line's length from output string.
This function is used only by Pigeonhole, which only uses it for empty
output strings, so it's not useful there. Also that behavior is somewhat
unexpected and confusing.
The pointer will never be NULL, as it's initialised pointing to an empty
string, and can only be overridden by setting it to another string. So
the test always failed. Instead, check the 1st character of the password.
Phil Carmody [Tue, 6 May 2014 09:44:38 +0000 (12:44 +0300)]
lib: cosmetic - rename parameters so that .h and .c files match
These functions were flagging sparse warnings, but those warnings are
trivially (robotically) dismissable if the parameters are identically
named in the two contexts. Opted for whichever name seemed to be more
meaningful or sensible. e.g. char** became p rather than s, as it's
a pointer more than a string.
Phil Carmody [Wed, 7 May 2014 13:52:22 +0000 (16:52 +0300)]
lib: a couple of trivial sparse cleanups
The #include isn't needed on modern linux, as the macros are already defined
The compiler seems to silently ignore redefinitions in system header files,
so didn't throw a warning, but probably should have, as redefinitions can lead
to insanity.
The cast just makes it explicit that we're changing the prototype.
Phil Carmody [Tue, 6 May 2014 15:10:55 +0000 (18:10 +0300)]
treewide sparse cleanup - make single-unit-only data static
Helps keep the global namespace clean. Not all the things suggested by
sparse have been moved. All DOVECOT_ABI_VERSION strings, and anything
replicated in all-settings.c by src/config/settings-get.pl has been
left untouched. Some of the latter could be moved, but the script would
need to be modified to replicate the 'static' (it outputs 'extern').
Timo Sirainen [Thu, 8 May 2014 10:45:37 +0000 (13:45 +0300)]
lib-storage: Code cleanups and potential crashfix.
Usually in blocks_count_lines() the full_input stream reading doesn't return
eof=true in the last read but only on the next. If this had changed for some
reason the code would have crashed in the assert checks.
Timo Sirainen [Thu, 8 May 2014 07:21:56 +0000 (10:21 +0300)]
run-test.sh: Valgrind version check was broken for v3.10+, removed it entirely.
RHEL 5.9 has valgrind v3.5 already, so there shouldn't really be any
important OSes using old valgrind that we need to support.
Timo Sirainen [Wed, 7 May 2014 16:47:12 +0000 (19:47 +0300)]
lib-imap: IMAP parser didn't parse atoms correctly that started with '~' character.
literal8 begins only after "~{", not immediately after "~" which is a valid
ATOM-CHAR.
Phil Carmody [Wed, 7 May 2014 15:39:23 +0000 (18:39 +0300)]
lib: fix md4/md5 buffer read overrun
uint_fast32_t may be 64 bits and read too many bytes at the end of the buffer.
This didn't actually break anything as long as there was 32 bits of readable
memory past the buffer.
Timo Sirainen [Wed, 7 May 2014 10:02:29 +0000 (13:02 +0300)]
liblib: Added unit test for hash methods to make sure they don't do read access beyond buffer.
This currently fails for MD4 and MD5, so they need to be fixed/replaced..
Timo Sirainen [Wed, 7 May 2014 09:26:38 +0000 (12:26 +0300)]
lib-compression: Fixed LZMA compression.
The code now looks more like the doc/examples/01_compress_easy.c distributed
with xz-utils. Most importantly this changes LZMA_OK to be allowed as a
result for lzma_code(zs, LZMA_FINISH).
Timo Sirainen [Mon, 5 May 2014 15:37:16 +0000 (18:37 +0300)]
mkdir_parents(): Handle mkdir() EEXIST errors that may happen during race conditions.
We don't care about EEXIST errors that happen when trying to mkdir() parent
directories, only if it happens when mkdir()ing the last directory.
Timo Sirainen [Mon, 5 May 2014 13:01:58 +0000 (16:01 +0300)]
lib-storage: mail_get_headers_utf8() now replaces NULs with spaces.
Perhaps there should also be another API function which actually allows
returning strings with NULs in them.
Timo Sirainen [Mon, 5 May 2014 12:05:20 +0000 (15:05 +0300)]
liblib: Added str_append_data(), which is simply a wrapper to buffer_append()
This is intended for appending data that may contain NUL characters that are
wanted to be added to the string.