]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
8 years agodsync: Improve process title during initialization
Timo Sirainen [Mon, 12 Dec 2016 10:53:36 +0000 (12:53 +0200)] 
dsync: Improve process title during initialization

If something is hanging, this should make it clear what exactly it is.

8 years agodoveadm-server: Show UNIX socket connections as <local> in process title
Timo Sirainen [Mon, 12 Dec 2016 10:42:53 +0000 (12:42 +0200)] 
doveadm-server: Show UNIX socket connections as <local> in process title

Earlier they were shown as empty string.

8 years agodoveadm: Add global doveadm_verbose_proctitle setting.
Timo Sirainen [Mon, 12 Dec 2016 10:43:47 +0000 (12:43 +0200)] 
doveadm: Add global doveadm_verbose_proctitle setting.

This previously existed only for doveadm-server, but adding it to doveadm
CLI makes it easier to do process title updates for it as well.

8 years agodoveadm: When connecting to doveadm-server via TCP, use 30s timeout
Timo Sirainen [Mon, 12 Dec 2016 10:51:42 +0000 (12:51 +0200)] 
doveadm: When connecting to doveadm-server via TCP, use 30s timeout

Should be enough, and better than the kernel's default, which might be a lot
more.

8 years agolib-storage: Do not try to recover missing list index
Aki Tuomi [Mon, 12 Dec 2016 08:40:20 +0000 (10:40 +0200)] 
lib-storage: Do not try to recover missing list index

Fixes Panic: file mailbox-list-index.c: line 342 (mailbox_list_index_parse_records): assertion failed: (node != NULL)

8 years agoconfigure: Fix some implicit function declarations
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()

8 years agoopenssl: Clear error queue after an incomplete SSL_shutdown
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.

8 years agoimapc: Don't send NOOP immediately after SELECT
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.

8 years agoconfig: Avoid excessive data stack usage when matching local_name
Timo Sirainen [Fri, 9 Dec 2016 11:11:11 +0000 (11:11 +0000)] 
config: Avoid excessive data stack usage when matching local_name

Moved config_filter_match_local_name() to its own function to make
adding the data stack frame easier.

Based on patch by J. Nick Koston

8 years agodoveadm-server: http: Fixed temp_path_prefix for iostream-temp.
Stephan Bosch [Fri, 9 Dec 2016 08:57:57 +0000 (09:57 +0100)] 
doveadm-server: http: Fixed temp_path_prefix for iostream-temp.

The temp_path_prefix was "/tmp", which is extended to "/tmp<hostname>.<pid>.<random>" by safe_mkstemp.

Obviously, mortal users cannot create a file like that, causing this error:
doveadm: Error: safe_mkstemp(/tmp) failed: Permission denied

The temp_path_prefix should have been "/tmp/doveadm.", as it is elsewhere as well.

8 years agolib: add t_strfgmtime and t_strftime
Martti Rannanjärvi [Thu, 8 Dec 2016 11:01:48 +0000 (13:01 +0200)] 
lib: add t_strfgmtime and t_strftime

8 years agolib: Improve seq_range_array_invert() unit tests
Timo Sirainen [Thu, 8 Dec 2016 17:37:30 +0000 (19:37 +0200)] 
lib: Improve seq_range_array_invert() unit tests

Try all possible combinations for seq=0..7 and seq=4294967288..4294967295
and make sure they're inverted correctly.

8 years agolib-storage: Add test for inversion of n->max
Aki Tuomi [Wed, 7 Dec 2016 08:19:02 +0000 (10:19 +0200)] 
lib-storage: Add test for inversion of n->max

In mail-search-simplify-args, ensure that
ALL NOT UID 3:* becomes UID 1:2

8 years agolib-storage: Fix typo in function name
Aki Tuomi [Tue, 6 Dec 2016 09:50:13 +0000 (11:50 +0200)] 
lib-storage: Fix typo in function name

8 years agolib: Comment seq_range_array_invert() that its values must be within min_seq..max_seq
Timo Sirainen [Thu, 8 Dec 2016 16:07:12 +0000 (18:07 +0200)] 
lib: Comment seq_range_array_invert() that its values must be within min_seq..max_seq

8 years agolib: Fix seq_range_array_invert() when input contains 2^32-1
Timo Sirainen [Thu, 8 Dec 2016 15:50:46 +0000 (17:50 +0200)] 
lib: Fix seq_range_array_invert() when input contains 2^32-1

This caused next_min_seq to be wrapped to 0, which was handled wrong later
on.

Fixes:
Panic: file mail-index-map.c: line 549 (mail_index_map_lookup_seq_range): assertion failed: (first_uid > 0)

8 years agoconfigure: Moved pandoc check to m4/dovecot.m4
Timo Sirainen [Thu, 8 Dec 2016 00:23:52 +0000 (09:23 +0900)] 
configure: Moved pandoc check to m4/dovecot.m4

8 years agocassandra: Treat "Request timed out" also as SQL_RESULT_ERROR_TYPE_WRITE_UNCERTAIN
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.

8 years agoconfigure: Fix HAVE_MYSQL_SSL_CIPHER check
Paul Howarth [Mon, 5 Dec 2016 09:53:06 +0000 (09:53 +0000)] 
configure: Fix HAVE_MYSQL_SSL_CIPHER check

8 years agoplugins: mail-crypt - fix static analysis pedantry
Phil Carmody [Tue, 6 Dec 2016 16:14:31 +0000 (18:14 +0200)] 
plugins: mail-crypt - fix static analysis pedantry

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 &&
             ^~~~~~~~~~~

Signed-off-by: Phil Carmody <phil@dovecot.fi>
8 years agolib/macros.h - protect old compilers from use of modern features
Phil Carmody [Mon, 5 Dec 2016 15:29:08 +0000 (17:29 +0200)] 
lib/macros.h - protect old compilers from use of modern features

no_sanitize(integer) is not in 3.5 (debian stable's version), but is
documented in 3.9. Exactly when it appeared isn't immediately obvious.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
8 years agoconfigure: Fix building without OpenSSL
Timo Sirainen [Sun, 4 Dec 2016 01:45:54 +0000 (03:45 +0200)] 
configure: Fix building without OpenSSL

AM_CONDITIONAL() needs to be part of the code path that is always run,
or it fails with:

configure: error: conditional "SSL_VERSION_GE_102" was never defined.

8 years agodsync: Fixed boolean expression in dsync_mailbox_import_deinit().
Stephan Bosch [Sat, 3 Dec 2016 19:48:30 +0000 (20:48 +0100)] 
dsync: Fixed boolean expression in dsync_mailbox_import_deinit().

Found with Clang -Wstrict-bool.

8 years agodsync: Fix log format string broken by earlier change
Timo Sirainen [Fri, 2 Dec 2016 20:42:24 +0000 (22:42 +0200)] 
dsync: Fix log format string broken by earlier change

8 years agolib-storage: Fix simplifying sequence sets and UID sets.
Timo Sirainen [Thu, 1 Dec 2016 00:29:44 +0000 (02:29 +0200)] 
lib-storage: Fix simplifying sequence sets and UID sets.

They were being handled completely wrong. The unit tests testing them
were also completely wrong.

8 years agolib: seq_range_array_*(): Fix seq2=2^32-1 handling
Timo Sirainen [Thu, 1 Dec 2016 00:26:08 +0000 (02:26 +0200)] 
lib: seq_range_array_*(): Fix seq2=2^32-1 handling

Adding/merging it when it already existed added duplicated seq_range.

8 years agolib-storage: Return vsize=0 from mailbox list index for empty mailboxes.
Timo Sirainen [Wed, 30 Nov 2016 22:56:11 +0000 (00:56 +0200)] 
lib-storage: Return vsize=0 from mailbox list index for empty mailboxes.

If it's known that the mailbox has no mails, there's no reason to open the
mailbox to see that its size is 0.

8 years agodict-client: Don't timeout lookups without waiting 1sec in dict ioloop.
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.

8 years agodsync: Add mailbox names as well as GUIDs to log messages.
Timo Sirainen [Fri, 2 Dec 2016 20:29:31 +0000 (22:29 +0200)] 
dsync: Add mailbox names as well as GUIDs to log messages.

8 years agodsync: When logging "Mailbox changed caused a desync", log also the reason.
Timo Sirainen [Thu, 1 Dec 2016 17:06:10 +0000 (19:06 +0200)] 
dsync: When logging "Mailbox changed caused a desync", log also the reason.

The reason is usually somewhere in the debug logs, but it's difficult to
find from there.

8 years agoconfig: Match multiple names in local_name
J. Nick Koston [Thu, 1 Dec 2016 07:38:02 +0000 (01:38 -0600)] 
config: Match multiple names in local_name

This can significantly reduce memory usage when using
a UCC certificate with multiple names by only loading
the certificate and key once.

8 years agoquota: Don't skip quota checks when moving mails between different quota roots.
Timo Sirainen [Thu, 24 Nov 2016 02:06:22 +0000 (04:06 +0200)] 
quota: Don't skip quota checks when moving mails between different quota roots.

8 years agolib-storage: Add struct mail_save_context.copy_src_mail
Timo Sirainen [Thu, 24 Nov 2016 18:40:15 +0000 (20:40 +0200)] 
lib-storage: Add struct mail_save_context.copy_src_mail

8 years agoman: Update doveadm director flush description
Timo Sirainen [Wed, 30 Nov 2016 00:17:12 +0000 (02:17 +0200)] 
man: Update doveadm director flush description

8 years agolib-storage: If mailbox_create() fails, don't leave box in partially opened state.
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.

8 years agomail-crypt: Remove dead assigment
Aki Tuomi [Tue, 29 Nov 2016 22:28:08 +0000 (00:28 +0200)] 
mail-crypt: Remove dead assigment

8 years agolib: Add test for hmac helper
Aki Tuomi [Tue, 29 Nov 2016 21:19:37 +0000 (23:19 +0200)] 
lib: Add test for hmac helper

8 years agolib: Add hmac helpers
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.

8 years agolib: add tests for HMAC-SHA256 from RFC 4231
Martti Rannanjärvi [Tue, 29 Nov 2016 13:20:26 +0000 (15:20 +0200)] 
lib: add tests for HMAC-SHA256 from RFC 4231

8 years agomail-crypt: Do not attempt to cache keys on failure
Aki Tuomi [Mon, 28 Nov 2016 21:05:16 +0000 (23:05 +0200)] 
mail-crypt: Do not attempt to cache keys on failure

8 years agoautogen: Use HTTPS for wiki
Aki Tuomi [Tue, 29 Nov 2016 08:57:49 +0000 (10:57 +0200)] 
autogen: Use HTTPS for wiki

8 years agolib-dcrypt: Add error handling for dcrypt_key_id_private
Aki Tuomi [Mon, 28 Nov 2016 13:20:01 +0000 (15:20 +0200)] 
lib-dcrypt: Add error handling for dcrypt_key_id_private

8 years agomail-crypt: Add error handling for mailbox_open in tests
Aki Tuomi [Mon, 28 Nov 2016 13:17:55 +0000 (15:17 +0200)] 
mail-crypt: Add error handling for mailbox_open in tests

8 years agodoveadm-mail-crypt: Skip existing keys properly
Aki Tuomi [Mon, 28 Nov 2016 13:15:21 +0000 (15:15 +0200)] 
doveadm-mail-crypt: Skip existing keys properly

When generating new keypairs, handle existing keys
correctly when skipping them.

8 years agomail-crypt: Do not attempt to cache freed keypair
Aki Tuomi [Mon, 28 Nov 2016 12:52:50 +0000 (14:52 +0200)] 
mail-crypt: Do not attempt to cache freed keypair

8 years agomail-crypt-acl: Use mailbox_get_last_error instead of error
Aki Tuomi [Mon, 28 Nov 2016 12:51:19 +0000 (14:51 +0200)] 
mail-crypt-acl: Use mailbox_get_last_error instead of error

8 years agomail-crypt: Fail if key is not found and save_version less than 2
Aki Tuomi [Mon, 28 Nov 2016 12:45:01 +0000 (14:45 +0200)] 
mail-crypt: Fail if key is not found and save_version less than 2

Fail if save version is set to 0 or 1, instead
of trying to use undefined value for public key.

8 years agomail-crypt: Skip undef values if OpenSSL is <1.0.2
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.

8 years agom4: Detect OpenSSL version 1.0.2
Aki Tuomi [Mon, 28 Nov 2016 11:32:16 +0000 (13:32 +0200)] 
m4: Detect OpenSSL version 1.0.2

valgrind cannot work in all cases if openssl
version is 1.0.2, so we need to know this to
selectively disable valgrind.

8 years agodovecot.m4: Add NOUNDEF option to run-test.sh
Aki Tuomi [Mon, 28 Nov 2016 12:12:23 +0000 (14:12 +0200)] 
dovecot.m4: Add NOUNDEF option to run-test.sh

Using this environment variable will disable
undefined value errors in valgrind.

8 years agolib-index: mail_transaction_log_file_sync(): Don't mix I/O errors and corruption
Timo Sirainen [Mon, 28 Nov 2016 11:52:40 +0000 (13:52 +0200)] 
lib-index: mail_transaction_log_file_sync(): Don't mix I/O errors and corruption

8 years agoacl: Fix compiler warning
Timo Sirainen [Mon, 28 Nov 2016 12:40:15 +0000 (14:40 +0200)] 
acl: Fix compiler warning

8 years agoacl-plugin: remove acl_defaults_from_inbox option
Martti Rannanjärvi [Mon, 28 Nov 2016 03:21:06 +0000 (05:21 +0200)] 
acl-plugin: remove acl_defaults_from_inbox option

INBOX ACLs will be used by default from now on.

8 years agolib-index: Fix assert-crash after "log file shrank" error.
Timo Sirainen [Mon, 28 Nov 2016 11:04:47 +0000 (13:04 +0200)] 
lib-index: Fix assert-crash after "log file shrank" error.

Fixes:
Panic: file buffer.c: line 316 (buffer_set_used_size): assertion failed: (used_size <= buf->alloc)

8 years agoAdd suppression for openssl leak
Aki Tuomi [Thu, 24 Nov 2016 23:45:29 +0000 (01:45 +0200)] 
Add suppression for openssl leak

8 years agomail-crypt: Add manpage
Aki Tuomi [Thu, 24 Nov 2016 22:45:35 +0000 (00:45 +0200)] 
mail-crypt: Add manpage

8 years agomail-crypt: Add mail-crypt plugin
Aki Tuomi [Thu, 24 Nov 2016 12:48:03 +0000 (14:48 +0200)] 
mail-crypt: Add mail-crypt plugin

8 years agolib-dcrypt: Use module_dir setting
Aki Tuomi [Fri, 25 Nov 2016 07:49:25 +0000 (09:49 +0200)] 
lib-dcrypt: Use module_dir setting

8 years agolib-dcrypt: Add module_dir setting
Aki Tuomi [Fri, 25 Nov 2016 07:48:43 +0000 (09:48 +0200)] 
lib-dcrypt: Add module_dir setting

This is needed for unit tests that require
dcrypt, so that they can load backend
without installing it first.

8 years agolib-http: client: Fixed assert failure occurring when a new connection fails for...
Stephan Bosch [Mon, 21 Nov 2016 22:19:26 +0000 (23:19 +0100)] 
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.

Fixes: Panic: file http-client-queue.c: line 481 (http_client_queue_connection_failure): assertion failed: (queue->cur_peer == NULL)
8 years agoglobal: Added missing copyright notices.
Stephan Bosch [Mon, 28 Nov 2016 02:26:01 +0000 (03:26 +0100)] 
global: Added missing copyright notices.

8 years agolib-storage: Fix raw storage to sync mailboxes correctly.
Timo Sirainen [Fri, 25 Nov 2016 14:14:16 +0000 (16:14 +0200)] 
lib-storage: Fix raw storage to sync mailboxes correctly.

Broken by b9da8540e665138b3cad0b637c08c0ab7d7a7eeb

8 years agolib-storage: Fix error handling in mailbox_list_index_refresh_force()
Timo Sirainen [Fri, 25 Nov 2016 13:34:46 +0000 (15:34 +0200)] 
lib-storage: Fix error handling in mailbox_list_index_refresh_force()

Broken by recent changes.

8 years agomkcert.sh: Use umask to create key file as 0600
Timo Sirainen [Mon, 21 Nov 2016 23:28:33 +0000 (01:28 +0200)] 
mkcert.sh: Use umask to create key file as 0600

Fixes a race condition between creation of the file and a later chmod.
This script was mostly meant as an example though, and not really for
production use. Especially because it generates self-signed certs.
CVE-2016-4983

8 years agomdbox: Rebuild index after it's been fsck'd
Timo Sirainen [Thu, 24 Nov 2016 16:12:18 +0000 (18:12 +0200)] 
mdbox: Rebuild index after it's been fsck'd

8 years agosdbox: Rebuild index after it's been fsck'd
Timo Sirainen [Thu, 24 Nov 2016 16:12:00 +0000 (18:12 +0200)] 
sdbox: Rebuild index after it's been fsck'd

8 years agolib-storge: Call mail_storage.list_index_corrupted() when needed
Timo Sirainen [Thu, 24 Nov 2016 15:52:01 +0000 (17:52 +0200)] 
lib-storge: Call mail_storage.list_index_corrupted() when needed

The callback is called whenever mailbox list index appears to be corrupted
with LAYOUT=index. The storage is responsible for adding to the index any
mailboxes that are missing.

8 years agolib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen [Thu, 24 Nov 2016 13:50:01 +0000 (15:50 +0200)] 
lib-storage: Add mail_storage.list_index_corrupted()

The actual implementation is in the next commit.

8 years agolib-index: Add mail_index_unset_fscked()
Timo Sirainen [Thu, 24 Nov 2016 15:16:30 +0000 (17:16 +0200)] 
lib-index: Add mail_index_unset_fscked()

This can be used to easily remove MAIL_INDEX_HDR_FLAG_FSCKD. It takes a
transaction parameter instead of sync_ctx because some index rebuilds
are done with a separate transaction while the sync_ctx is rolled back.

8 years agolib-index: fsck now adds MAIL_INDEX_HDR_FLAG_FSCKD to header.
Timo Sirainen [Thu, 24 Nov 2016 13:49:15 +0000 (15:49 +0200)] 
lib-index: fsck now adds MAIL_INDEX_HDR_FLAG_FSCKD to header.

It can only be removed by an explicit header update.

8 years agolib-storage: Rename mailbox_list_index.corrupted to corrupted_names_or_parents
Timo Sirainen [Thu, 24 Nov 2016 13:41:38 +0000 (15:41 +0200)] 
lib-storage: Rename mailbox_list_index.corrupted to corrupted_names_or_parents

Makes it clearer what exactly the flag means.

8 years agolib-index: If index open fails with fsck, retry opening once.
Timo Sirainen [Thu, 24 Nov 2016 13:14:06 +0000 (15:14 +0200)] 
lib-index: If index open fails with fsck, retry opening once.

The fsck should have fixed the log offsets and open should work.

8 years agolib-index: fsck: Fix log_file_head|tail_offset properly
Timo Sirainen [Thu, 24 Nov 2016 13:12:21 +0000 (15:12 +0200)] 
lib-index: fsck: Fix log_file_head|tail_offset properly

8 years agolib-dcrypt: Add assert that vfs is initialized
Aki Tuomi [Fri, 25 Nov 2016 08:22:18 +0000 (10:22 +0200)] 
lib-dcrypt: Add assert that vfs is initialized

8 years agolib-storage: Fail if no namespaces have list=yes
Timo Sirainen [Thu, 24 Nov 2016 17:53:17 +0000 (19:53 +0200)] 
lib-storage: Fail if no namespaces have list=yes

The previous check allowed all namespaces to have list=children. This
crashed later on in mail_namespaces_get_root_sep(), because it couldn't
find any list=yes namespaces.

8 years agolib-index: Compiler warning fix
Timo Sirainen [Thu, 24 Nov 2016 22:17:45 +0000 (00:17 +0200)] 
lib-index: Compiler warning fix

8 years agolib-mail: Add randomness test to test-mail-html2text
Timo Sirainen [Tue, 22 Nov 2016 16:34:53 +0000 (18:34 +0200)] 
lib-mail: Add randomness test to test-mail-html2text

8 years agolib-mail: Fix assert-crash in mail_html2text_more() with invalid input.
Timo Sirainen [Tue, 22 Nov 2016 16:33:12 +0000 (18:33 +0200)] 
lib-mail: Fix assert-crash in mail_html2text_more() with invalid input.

parse_data() continues forward thinking that it might have valid input,
until it has enough data and realizes that there's nothing valid. This
triggers:

Panic: file mail-html2text.c: line 312 (mail_html2text_more): assertion failed: (pos >= buf_orig_size)

8 years agolib: Clarify that buffer_write() zero-fills buffer when writing past its size
Timo Sirainen [Sat, 19 Nov 2016 00:32:21 +0000 (02:32 +0200)] 
lib: Clarify that buffer_write() zero-fills buffer when writing past its size

8 years agoglobal: Code cleanup - avoid passing NULL to functions with non-null parameter
Timo Sirainen [Fri, 18 Nov 2016 23:54:14 +0000 (01:54 +0200)] 
global: Code cleanup - avoid passing NULL to functions with non-null parameter

8 years agoglobal: Avoid unnecessary unsigned integer wraps.
Timo Sirainen [Sat, 19 Nov 2016 00:00:25 +0000 (02:00 +0200)] 
global: Avoid unnecessary unsigned integer wraps.

Avoids complains from clang -fsanitize=integer

8 years agoglobal: Avoid loops unnecessarily decreasing below zero.
Timo Sirainen [Fri, 18 Nov 2016 23:59:03 +0000 (01:59 +0200)] 
global: Avoid loops unnecessarily decreasing below zero.

Avoids complains from clang -fsanitize=integer

8 years agolib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen [Fri, 18 Nov 2016 23:57:40 +0000 (01:57 +0200)] 
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS

8 years agolib-index: mail_index_map_register_ext(ext_offset=-1) now sets hdr_offset=-1
Timo Sirainen [Fri, 18 Nov 2016 23:56:19 +0000 (01:56 +0200)] 
lib-index: mail_index_map_register_ext(ext_offset=-1) now sets hdr_offset=-1

It shouldn't make any difference, but this is a less confusing value.

8 years agolib: Add ATTR_UNSIGNED_WRAPS for disabling clang -fsanitize=integer
Timo Sirainen [Fri, 18 Nov 2016 23:39:42 +0000 (01:39 +0200)] 
lib: Add ATTR_UNSIGNED_WRAPS for disabling clang -fsanitize=integer

8 years agolib-index: Compiler warning fix.
Timo Sirainen [Thu, 24 Nov 2016 21:26:40 +0000 (23:26 +0200)] 
lib-index: Compiler warning fix.

8 years agolib-storage: Rotate dovecot.list.index.log* more often.
Timo Sirainen [Wed, 23 Nov 2016 21:19:05 +0000 (23:19 +0200)] 
lib-storage: Rotate dovecot.list.index.log* more often.

The history in these files isn't as important as in mailbox indexes.
Reduce disk space usage by rotating them more often and deleting the
.log.2 more quickly.

8 years agolib-index: Add mail_index_set_log_rotation()
Timo Sirainen [Wed, 23 Nov 2016 21:12:29 +0000 (23:12 +0200)] 
lib-index: Add mail_index_set_log_rotation()

8 years agolib-storage: Try harder to rename a corrupted mailbox name to its old name.
Timo Sirainen [Wed, 23 Nov 2016 20:42:03 +0000 (22:42 +0200)] 
lib-storage: Try harder to rename a corrupted mailbox name to its old name.

If the old name exists, use it as a prefix for the new name. This is
especially useful when restoring autocreated mailboxes. A new mailbox
could have already been autocreated, but it's still useful to have
the broken one renamed with the same prefix, so it'll be clear that
these mailboxes should be merged.

8 years agodsync: Do not try replace remote folder GUID when doing oneway sync
Aki Tuomi [Thu, 24 Nov 2016 17:32:44 +0000 (19:32 +0200)] 
dsync: Do not try replace remote folder GUID when doing oneway sync

Oneway sync tried to replace remote folder's GUID when
running in one way mode. This causes trouble, e.g.
when running with imapc, because you can't do this.

8 years agolib-storage: Fix rotation of dovecot.list.index.log
Timo Sirainen [Wed, 23 Nov 2016 16:43:17 +0000 (18:43 +0200)] 
lib-storage: Fix rotation of dovecot.list.index.log

After b9da8540e665138b3cad0b637c08c0ab7d7a7eeb the tail offsets weren't
being updated anymore when mail_index_sync_next() wasn't used to skip
over all the data. Mailbox list index wasn't doing this, and so the log
was never rotated since tail_offset was never equal to head_offset.

8 years agoimapc: Fix assert that checks if mail is expunged locally.
Timo Sirainen [Wed, 23 Nov 2016 15:14:48 +0000 (17:14 +0200)] 
imapc: Fix assert that checks if mail is expunged locally.

The EXPUNGE may have been sent while imapc_sync_index() was issuing
remote imapc commands. It would end up being in delayed_expunged_uids,
so the assert needs to check that too.

Fixes:
Panic: file imapc-sync.c: line 290 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq))

8 years agoimapc: Cleanup - change delayed_expunged_uids to seq_range.
Timo Sirainen [Wed, 23 Nov 2016 15:14:14 +0000 (17:14 +0200)] 
imapc: Cleanup - change delayed_expunged_uids to seq_range.

This simplifies the next commit.

8 years agoauth: Don't crash expanding %variables when username isn't set.
Timo Sirainen [Wed, 23 Nov 2016 13:57:03 +0000 (15:57 +0200)] 
auth: Don't crash expanding %variables when username isn't set.

This continues the auth-policy fix in
c3d3faa4f72a676e183f34be960cff13a5a725ae

8 years agosdbox: Don't log an error if stub is added twice
Timo Sirainen [Wed, 23 Nov 2016 11:25:54 +0000 (13:25 +0200)] 
sdbox: Don't log an error if stub is added twice

There's no locking for them, so it's fine if two processes add the same
mail. The second one could be ignored, but it was a bit easier to just
let it rename over the first one.

8 years agoauth: Fix auth-policy crash when username is NULL
Aki Tuomi [Wed, 23 Nov 2016 11:16:19 +0000 (13:16 +0200)] 
auth: Fix auth-policy crash when username is NULL

If SASL request is invalid, or incomplete, and username
is left NULL, handle it gracefully by adding just
NUL byte in auth policy digest for username.

8 years agolib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching
Josef 'Jeff' Sipek [Tue, 22 Nov 2016 15:21:24 +0000 (10:21 -0500)] 
lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching

If we are going to be using the storage for caching, we should check that
the storage actually supports mail stubs.

8 years agolib-fts: Add randomness test to test-fts-tokenizer
Timo Sirainen [Tue, 22 Nov 2016 16:00:13 +0000 (18:00 +0200)] 
lib-fts: Add randomness test to test-fts-tokenizer

8 years agolib-fts: Make sure address tokenizer can't return empty tokens.
Timo Sirainen [Tue, 22 Nov 2016 14:35:58 +0000 (16:35 +0200)] 
lib-fts: Make sure address tokenizer can't return empty tokens.

This happened when address was a token that first looked like it could be
a valid address, but then got truncated due to reaching maxlen, followed
by truncating the UTF8-sequence and finally all the rest of the '-' or
'.' chars that were valid at the beginning of the address are stripped
away by fts_tokenizer_delete_trailing_invalid_char(), leaving nothing left.

Fixes:
Panic: file fts-tokenizer.c: line 206 (fts_tokenizer_next): assertion failed: (ret <= 0 || (*token_r)[0] != '\0')

8 years agolib-fts: Fix fts_tokenizer_delete_trailing_partial_char() unit test
Timo Sirainen [Tue, 22 Nov 2016 15:31:02 +0000 (17:31 +0200)] 
lib-fts: Fix fts_tokenizer_delete_trailing_partial_char() unit test