Timo Sirainen [Mon, 12 Dec 2016 05:19:55 +0000 (07:19 +0200)]
global: Change string position/length from unsigned int to size_t
Mainly to avoid truncating >4GB strings, which might potentially cause
some security holes. Normally there are other limits, which prevent such
excessive strings from being created in the first place.
I'm sure this didn't find everything. Maybe everything could be found with
compiler warnings. -Wconversion kind of does it, but it gives way too many
unnecessary warnings.
Timo Sirainen [Mon, 12 Dec 2016 01:55:54 +0000 (03:55 +0200)]
lib: Remove t_buffer_*_type()
The t_buffer_*() shouldn't normally be used anyway except in some low-level
string/buffer manipulation code, so there's not much point in trying to make
easier to use versions of them.
Timo Sirainen [Thu, 15 Dec 2016 17:03:39 +0000 (19:03 +0200)]
director: Fix USER-KICK and USER-KICK-ALT forwarding
The internal IPC command was prefixed, which caused the remote director
to reject the commands and disconnect:
director(...): Command proxy: Unknown command proxy
director(...): Remote sent invalid protocol data recently, waiting 57 secs before allowing further communication
Timo Sirainen [Thu, 15 Dec 2016 13:20:02 +0000 (15:20 +0200)]
lib-storage: Fix "*" in SEARCH seqset/uidset
4294967295 is used for "*", which matches the last existing message.
Which we don't know what it is at the time of search args simplification,
so avoid making any assumptions about it.
It's a bit ugly that 4294967295 can't be used as a valid UID, but this
restriction has already existed since the beginning of Dovecot. A future
alternative might be to add MAIL_SEARCH_ARG_FLAG_SEQSET_WITH_STAR, but
that's a bit complicated change.
Aki Tuomi [Wed, 14 Dec 2016 09:42:56 +0000 (11:42 +0200)]
auth-policy: Allow unsupported attributes in response
Do not choke if we receive unsupported attributes in
response. This allows better interoperability with
different systems that are getting signals from
auth policy server that are not (yet) supported by
dovecot.
This needs to be silenced since it's logging errors of variable
expansions that are not meant to be successful. The function is used
here just for filling the attr_names array in ldap_field_find_context
and the resulting string is not used.
Stephan Bosch [Wed, 14 Dec 2016 01:51:54 +0000 (02:51 +0100)]
lib-imap: imap-bodystructure: Prevent writing erroneous whitespace between items in an envelope address list.
Both imap_bodystructure_write() and imap_body_parse_from_bodystructure() produced such invalid output.
This caused an RFC 3501 violation in IMAP FETCH BODY and BODYSTRUCTURE responses.
Timo Sirainen [Tue, 13 Dec 2016 12:51:20 +0000 (14:51 +0200)]
acl: Don't set acl_defaults_from_inbox=yes as default after all.
Reverts b56d462fff46511b7efa0ccf254ba93d72322920 and removes the FIXME.
Some people might actually want to give someone else access to their INBOX
but not to all the other mailboxes. We should make it possible to use the
"" mailbox name as the default ACL instead.
Timo Sirainen [Mon, 12 Dec 2016 10:37:34 +0000 (12:37 +0200)]
dsync: Fix .dovecot-sync.lock timeout checking
Whenever the lock file was recreated, the lock timeout was reset. Switched
to using file_create_locked(), which already solves this problem and has
compatible locking.
Paul Howarth [Mon, 5 Dec 2016 15:17:30 +0000 (15:17 +0000)]
configure: Fix some implicit function declarations
Some configure tests fail unexpectedly if the compiler flag
-Werror=implicit-function-declarations is enabled, which can result
in the wrong implementations being used.
This compiler flag is now enabled by default in Fedora Rawhide:
https://fedoraproject.org/wiki/Changes/Fedora26CFlags
<stdlib.h> is needed for exit()
<string.h> is needed for strcpy()
manuel [Wed, 7 Dec 2016 13:23:12 +0000 (14:23 +0100)]
openssl: Clear error queue after an incomplete SSL_shutdown
If the SSL_shutdown-call fails (e.g. because the underlaying socket has
already been closed) OpenSSL puts the corresponding error into the
queue. We don't care about details so we need to clear the queue.
Otherwise the error will be pulled while error checking the next OpenSSL
call of an unrelated connection.
Timo Sirainen [Fri, 9 Dec 2016 13:06:05 +0000 (15:06 +0200)]
imapc: Don't send NOOP immediately after SELECT
NOOP is normally used by mailbox syncing to check if there are any changes
done by other concurrent IMAP sessions. But doing it immediately after
SELECT is unnecessary, because nothing could have changed.
Timo Sirainen [Tue, 6 Dec 2016 22:14:08 +0000 (00:14 +0200)]
cassandra: Treat "Request timed out" also as SQL_RESULT_ERROR_TYPE_WRITE_UNCERTAIN
CASS_ERROR_SERVER_WRITE_TIMEOUT is "Write timeout" as reported by Cassandra
server, while CASS_ERROR_LIB_REQUEST_TIMED_OUT is timeout as reported by the
Cassandra library.
Clang cannot see that ret is -1, 0, or 1 upon assigment, and therefore
-1 or 0 upon entry into the if block. Therefore it considers ret==0
not to be a tautology if ret!=-1, and thus falsifiable. It concludes
that bad things can later happen.
The easiest way to persuade it otherwise and make it clear to a human
that things are sane is to make the first error check to be for any
negative ret value, which forces the else path to explicitly imply
ret==0, which means that clause can also be removed. Just removing the
ret==0 doesn't make it so clear to the human that there's no third case.
The final change is simply to mimic the ret==-1 to ret<0 change earlier.
clang's error message:
doveadm-mail-crypt.c:290:14: error: variable 'pubid' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
} else if (ret == 0 &&
^~~~~~~~
doveadm-mail-crypt.c:304:35: note: uninitialized use occurs here
res->id = p_strdup(_ctx->pool, pubid);
^~~~~
doveadm-mail-crypt.c:290:14: note: remove the '&&' if its condition is always true
} else if (ret == 0 &&
^~~~~~~~~~~
Timo Sirainen [Wed, 30 Nov 2016 13:59:01 +0000 (15:59 +0200)]
dict-client: Don't timeout lookups without waiting 1sec in dict ioloop.
What could have happened was:
- dict-client sends a request to dict-server
- dict-client process starts doing something else
- dict-server answers
- dict-client process continues doing something else for over 30 seconds,
not reading the dict-server answer
- dict-client process gets back to dict ioloop, which runs the timeout
before checking if there is anything available for reading.
Now we'll wait for 1 second in the last dict ioloop before assuming that
there's a timeout.
Timo Sirainen [Wed, 30 Nov 2016 10:34:45 +0000 (12:34 +0200)]
lib-storage: If mailbox_create() fails, don't leave box in partially opened state.
For example with sdbox it may have opened the indexes, but not set mailbox's
GUID. A following MAILBOX_METADATA_GUID would then assert-crash because GUID
is empty.
Aki Tuomi [Tue, 29 Nov 2016 21:18:56 +0000 (23:18 +0200)]
lib: Add hmac helpers
These run hmac for given data with given parameters
and returns stack allocated buffer. They are helpful
when doing lots of HMACs, such as the AWS4 signing
protocol.
Aki Tuomi [Mon, 28 Nov 2016 11:36:56 +0000 (13:36 +0200)]
mail-crypt: Skip undef values if OpenSSL is <1.0.2
OpenSSL 1.0.1 and earlier generate undef warnings due
to using stack as randomness source in a way that
valgrind does not like, so we disable undef value
checks for mail-crypt-plugin.