]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
11 years agolib: test-istream-tee - more randomisation to the tests
Phil Carmody [Thu, 10 Jul 2014 12:59:53 +0000 (15:59 +0300)] 
lib: test-istream-tee - more randomisation to the tests
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-istream-tee - verify _read returns correct values after _set_size()
Phil Carmody [Thu, 10 Jul 2014 12:59:53 +0000 (15:59 +0300)] 
lib: test-istream-tee - verify _read returns correct values after _set_size()
Previously, only an increase of 1 in the size was tested. This ensures that
0 and numbers > 1 are also tested.

Also add _idx to the asserts, so we know where in the loop it failed.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-istream-concat - add simultanious limit streams back into the mix
Phil Carmody [Thu, 10 Jul 2014 12:59:53 +0000 (15:59 +0300)] 
lib: test-istream-concat - add simultanious limit streams back into the mix
Return to the previous complex nested stream-type case.

1 time in 10, it tests the simple case of:

test_stream \
test_stream -}- concat_stream
test_stream /
(2-11 of these)

9 times in 10, it tests this configuration instead:

test_stream \                  / limit_stream
test_stream -}- concat_stream {- limit_stream
test_stream /                  \ limit_stream
(2-11 of these)                 (1-9 of these)

Since 31efe2d04793 lib: istream-concat read() returned -2 too early., all tests
pass every time.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-istream-concat - test only concat, not simultanious limit streams
Phil Carmody [Thu, 10 Jul 2014 12:59:53 +0000 (15:59 +0300)] 
lib: test-istream-concat - test only concat, not simultanious limit streams
Test just concat functionality in this unit test. Simultanious access of
limit streams can be tested elsewhere.

Without the fix in:
  31efe2d04793 lib: istream-concat read() returned -2 too early.
The failure previously seen in test-istream-concat would be still reproducable:
test-istream-concat.c:84: Assert failed: size >= TEST_MAX_BUFFER_SIZE
istream concat random ................................................ : FAILED
test: random seed #1 was 1403118493

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-fs: Added FS_PROPERTY_COPY_METADATA and fs_set_metadata() tracking.
Timo Sirainen [Thu, 10 Jul 2014 12:40:08 +0000 (15:40 +0300)] 
lib-fs: Added FS_PROPERTY_COPY_METADATA and fs_set_metadata() tracking.

11 years agolib-fs: Added username and session_id to struct fs directly.
Timo Sirainen [Wed, 9 Jul 2014 12:55:59 +0000 (15:55 +0300)] 
lib-fs: Added username and session_id to struct fs directly.

11 years agolib-fs: Added fs_settings.username and .session_id
Timo Sirainen [Wed, 9 Jul 2014 12:24:21 +0000 (15:24 +0300)] 
lib-fs: Added fs_settings.username and .session_id

11 years agolib-storage: Added struct mail_user.session_id
Timo Sirainen [Wed, 9 Jul 2014 12:20:59 +0000 (15:20 +0300)] 
lib-storage: Added struct mail_user.session_id

11 years agolib-http: Made sure that connections that are still connecting to the server aren...
Stephan Bosch [Wed, 9 Jul 2014 07:55:27 +0000 (10:55 +0300)] 
lib-http: Made sure that connections that are still connecting to the server aren't marked as idle.

11 years agolib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen [Mon, 7 Jul 2014 13:21:08 +0000 (16:21 +0300)] 
lib-index: Don't update log_file_tail_offset unnecessarily.
Update it only if we're already writing to transaction log anyway or if
we're required to update the offset because mail_index_sync_commit() has
increased it past non-external transactions (this is especially important
with mdbox map index).

11 years agolib-storage: Minor code cleanup to istream-mail.
Timo Sirainen [Mon, 7 Jul 2014 10:24:22 +0000 (13:24 +0300)] 
lib-storage: Minor code cleanup to istream-mail.
eof=TRUE shouldn't be possible with ret=-2, so this just makes it clearer
what the code's intention is.

11 years agolib: i_stream_read_copy_from_parent() needs to update access counter also when return...
Timo Sirainen [Mon, 7 Jul 2014 10:15:33 +0000 (13:15 +0300)] 
lib: i_stream_read_copy_from_parent() needs to update access counter also when returning -2
This finishes the 467a4d19f873 fix.

11 years agovirtual: Fixed assert-crashes where trying to open an already opened backend mailbox.
Timo Sirainen [Sun, 6 Jul 2014 16:08:59 +0000 (19:08 +0300)] 
virtual: Fixed assert-crashes where trying to open an already opened backend mailbox.

11 years agolib: istream-tee wasn't returning data correctly always.
Timo Sirainen [Fri, 4 Jul 2014 12:33:12 +0000 (15:33 +0300)] 
lib: istream-tee wasn't returning data correctly always.
This fixes an assert-crash in istream-tee.c. (Hopefully it was always
assert-crashing instead of returning corrupted data.)

11 years agolib: failures - cosmetic write_full cleanup
Phil Carmody [Fri, 4 Jul 2014 11:48:44 +0000 (14:48 +0300)] 
lib: failures - cosmetic write_full cleanup
Error message should have a trailing newline.
Use the POSIX macro for stderr's file number, rather than its numeric value.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agoconfig: parser - trivial error message typo
Phil Carmody [Fri, 4 Jul 2014 11:18:25 +0000 (14:18 +0300)] 
config: parser - trivial error message typo
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolmtp: Small code cleanup
Timo Sirainen [Fri, 4 Jul 2014 11:17:54 +0000 (14:17 +0300)] 
lmtp: Small code cleanup

11 years agoimap: If FETCH fails because mail has already been expunged, don't log an error.
Timo Sirainen [Fri, 4 Jul 2014 11:16:16 +0000 (14:16 +0300)] 
imap: If FETCH fails because mail has already been expunged, don't log an error.

11 years agolib-storage: Bodystructure parsing flags weren't updated correctly on error conditions.
Timo Sirainen [Fri, 4 Jul 2014 11:15:41 +0000 (14:15 +0300)] 
lib-storage: Bodystructure parsing flags weren't updated correctly on error conditions.
This fixes an assert-crash sometimes when mail parsing failed.

11 years agolib-storage: istream-mail updates mail->expunged if it notices ENOENT from parent...
Timo Sirainen [Fri, 4 Jul 2014 11:14:21 +0000 (14:14 +0300)] 
lib-storage: istream-mail updates mail->expunged if it notices ENOENT from parent stream.

11 years agolib-storage: Log mail istream read failures in one place.
Timo Sirainen [Fri, 4 Jul 2014 11:01:53 +0000 (14:01 +0300)] 
lib-storage: Log mail istream read failures in one place.
Also handle ENOENT errors by checking if the mail has already been expunged,
and if so don't log an error, just return "mail is already expunged" error
to client.

11 years agoWhen creating istream-error, give an error string whenever possible.
Timo Sirainen [Fri, 4 Jul 2014 10:16:59 +0000 (13:16 +0300)] 
When creating istream-error, give an error string whenever possible.

11 years agolib-storage: If mail body reading failed, the error message may have contained only...
Timo Sirainen [Fri, 4 Jul 2014 10:16:01 +0000 (13:16 +0300)] 
lib-storage: If mail body reading failed, the error message may have contained only minimal errno string.
Even though the istream could have had a much better internal error message.
So show it.

11 years agolib-dict: Removed NFS flushing from dict-file backend.
Timo Sirainen [Fri, 4 Jul 2014 08:48:27 +0000 (11:48 +0300)] 
lib-dict: Removed NFS flushing from dict-file backend.

11 years agombox: If GUID lookup fails because mbox_min_index_size skipped indexes, say so in...
Timo Sirainen [Thu, 3 Jul 2014 19:24:05 +0000 (22:24 +0300)] 
mbox: If GUID lookup fails because mbox_min_index_size skipped indexes, say so in error message.

11 years agoacl: Global ACLs now support "patterns with spaces inside quotes"
Timo Sirainen [Thu, 3 Jul 2014 19:17:49 +0000 (22:17 +0300)] 
acl: Global ACLs now support "patterns with spaces inside quotes"

11 years agoacl: Oops, ignore_acls check was reversed.
Timo Sirainen [Thu, 3 Jul 2014 19:16:48 +0000 (22:16 +0300)] 
acl: Oops, ignore_acls check was reversed.

11 years agolib-compression: Compression ostreams may have caused parent ostream to use too much...
Timo Sirainen [Thu, 3 Jul 2014 18:55:31 +0000 (21:55 +0300)] 
lib-compression: Compression ostreams may have caused parent ostream to use too much memory.

11 years agolib: Added o_stream_flush_parent_if_needed() for wrapper ostreams.
Timo Sirainen [Thu, 3 Jul 2014 18:54:52 +0000 (21:54 +0300)] 
lib: Added o_stream_flush_parent_if_needed() for wrapper ostreams.

11 years agoacl: Create struct acl_mailbox also for shared root namespace mailboxes.
Timo Sirainen [Thu, 3 Jul 2014 17:42:08 +0000 (20:42 +0300)] 
acl: Create struct acl_mailbox also for shared root namespace mailboxes.
This fixes crashes where imap_acl code attempts to access ACLs for
nonexistent mailboxes inside shared root namespace. Alternatively the
imap_acl plugin could have checked the nonexistence of ACLs but this is
probably easier and more guaranteed to work.

11 years agolmtp: Removed code that attempts to deduplicate mail files by copying them between...
Timo Sirainen [Thu, 3 Jul 2014 17:28:16 +0000 (20:28 +0300)] 
lmtp: Removed code that attempts to deduplicate mail files by copying them between user mailboxes.
This sometimes started failing if the mail that was being used for copying
was deleted by the user. There's no good way for lmtp code to fix that
situation.

If deduplication is needed, it could be implemented in a more generic way
inside mailbox_copy() where after initial copy it would store the
destination struct mail to src_mail->last_copy_dest_mail. If another mail is
copied, the last_copy_dest_mail could be attempted to be used for the
copying and if that doesn't work it would fallback to regular copying. This
should probably be attempted only for lda/lmtp processes as it would just
cause extra overhead for others.

11 years agoCompile fix for old systems without SSL_OP_NO_COMPRESSION
Timo Sirainen [Thu, 3 Jul 2014 16:34:57 +0000 (19:34 +0300)] 
Compile fix for old systems without SSL_OP_NO_COMPRESSION

11 years agofts-lucene: Delay initialization to fix assert-crash with mbox
Timo Sirainen [Thu, 3 Jul 2014 16:27:45 +0000 (19:27 +0300)] 
fts-lucene: Delay initialization to fix assert-crash with mbox

11 years agoopenssl: optionally disable TLS compression
Phil Carmody [Thu, 3 Jul 2014 16:17:16 +0000 (19:17 +0300)] 
openssl: optionally disable TLS compression
Make ssl compression optional, but enabled by default. Other ssl options
might be tweakable in the future, so have a single ssl_options string,
and explode it into individual flags. (Compare postfix configuration.)
Based on an idea by Andreas Schulze <sca@andreasschulze.de>

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-storage: Added mail_namespace_is_shared_user_root() and used it where useful.
Timo Sirainen [Thu, 3 Jul 2014 16:12:02 +0000 (19:12 +0300)] 
lib-storage: Added mail_namespace_is_shared_user_root() and used it where useful.
Most importantly this should fix a crash in ACL plugin where type=shared
namespace was used without any kind of per-user prefix/location (i.e. it
probably should have been a type=public namespace instead).

11 years agoacl: Compile fix caused by previous change
Timo Sirainen [Thu, 3 Jul 2014 16:10:33 +0000 (19:10 +0300)] 
acl: Compile fix caused by previous change

11 years agolib-storage: Move "shared" storage name to mail-storage-private.h where it can be...
Timo Sirainen [Thu, 3 Jul 2014 16:03:59 +0000 (19:03 +0300)] 
lib-storage: Move "shared" storage name to mail-storage-private.h where it can be used.

11 years agolib-storage: Minor parsing fix to namespace types: Use strcmp() instead of strncmp().
Timo Sirainen [Thu, 3 Jul 2014 16:00:46 +0000 (19:00 +0300)] 
lib-storage: Minor parsing fix to namespace types: Use strcmp() instead of strncmp().

11 years agovirtual: Never keep more than specified number of physical mailboxes open.
Timo Sirainen [Thu, 3 Jul 2014 14:44:32 +0000 (17:44 +0300)] 
virtual: Never keep more than specified number of physical mailboxes open.
This should make virtual mailboxes work for users who have a a ton of
mailboxes with a ton of mails. Earlier code would likely have failed either
with "Too many open files" or crashed with "Out of memory".

You can change the max number of open mailboxes with:

plugin {
  virtual_max_open_mailboxes = 64
}

The default is 64.

11 years agolib-index: Fixed error handling in mail_index_open()
Timo Sirainen [Thu, 3 Jul 2014 14:40:37 +0000 (17:40 +0300)] 
lib-index: Fixed error handling in mail_index_open()

11 years agolib-index: Index cache could have kept too many indexes open.
Timo Sirainen [Thu, 3 Jul 2014 14:29:58 +0000 (17:29 +0300)] 
lib-index: Index cache could have kept too many indexes open.
If a lot of indexes were allocated and then later on they were opened and
closed, the alloc-cache simply kept all the indexes open even after they
should have been closed.

11 years agolib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item...
Timo Sirainen [Thu, 3 Jul 2014 13:07:09 +0000 (16:07 +0300)] 
lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Hopefully there wasn't any code that actually did this, but it's safer this
way anyway. Perhaps it could be even made to assert-crash if it happens.

11 years agolib-storage: mailbox_get_metadata() now opens the mailbox only if it's necessary.
Timo Sirainen [Thu, 3 Jul 2014 12:26:32 +0000 (15:26 +0300)] 
lib-storage: mailbox_get_metadata() now opens the mailbox only if it's necessary.

11 years agovirtual: Recent flags dropping wasn't working as intended.
Timo Sirainen [Thu, 3 Jul 2014 11:54:43 +0000 (14:54 +0300)] 
virtual: Recent flags dropping wasn't working as intended.
In the old code '+' meant that \Recent flags were dropped also when the
virtual mailbox was EXAMINEd. SELECTing a mailbox always dropped \Recent
flags regardless of the '+' flag.

What should have happened (and does in new code) is that the \Recent flags
are dropped only on SELECT and only if '+' flag is set.

11 years agofts: If we detect corrupted fts expunge log, unlink it.
Timo Sirainen [Thu, 3 Jul 2014 11:37:08 +0000 (14:37 +0300)] 
fts: If we detect corrupted fts expunge log, unlink it.
This avoids the same error repeating forever.

11 years agolib-imap: test-imap-url - cosmetic whitespace cleanup
Phil Carmody [Thu, 3 Jul 2014 09:44:50 +0000 (12:44 +0300)] 
lib-imap: test-imap-url - cosmetic whitespace cleanup
Only whitespace changes. All trailing space removed, reindented:
 $ grep '[[:space:]]$' src/lib-imap/test-imap-url.c
 $ git diff -w
 $

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: test-imap-url - quieten successful sub-tests
Phil Carmody [Thu, 3 Jul 2014 09:42:11 +0000 (12:42 +0300)] 
lib-imap: test-imap-url - quieten successful sub-tests
Every sub-component of a URL doesn't need its own successful log, so use the
only-print-on-error test_out_quiet() function instead. All failures are just
as explicit as before.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: test-common - add test_out_quiet() to reduce verbosity
Phil Carmody [Thu, 3 Jul 2014 09:42:11 +0000 (12:42 +0300)] 
lib-test: test-common - add test_out_quiet() to reduce verbosity
Like test_out() but only prints anything if success is false.
This makes it quite much like test_assert(), except that it
doesn't print the code fragment, it prints a custom string.
However, it still counts as a test in the total count, unlike
test_assert*()s.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: test_imap_url didn't compare port numbers
Phil Carmody [Thu, 3 Jul 2014 09:42:11 +0000 (12:42 +0300)] 
lib-imap: test_imap_url didn't compare port numbers
It only compare them when they were unset, and defaulting both to 0.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agoquota: Quota count tracking still was still incorrect in over-quota conditions.
Timo Sirainen [Thu, 3 Jul 2014 08:37:07 +0000 (11:37 +0300)] 
quota: Quota count tracking still was still incorrect in over-quota conditions.

11 years agolib-index: Recent idx->seq change in strmap forgot to initialize uid_lookup_seq in...
Timo Sirainen [Wed, 2 Jul 2014 20:41:10 +0000 (23:41 +0300)] 
lib-index: Recent idx->seq change in strmap forgot to initialize uid_lookup_seq in one place.

11 years agotest-quota-util: Link to quota-util.lo instead of .o
Timo Sirainen [Wed, 2 Jul 2014 17:53:46 +0000 (20:53 +0300)] 
test-quota-util: Link to quota-util.lo instead of .o
Hopefully fixes dependency tracking to work correctly?

11 years agoquota: Fixed quota_transaction_is_over() to handle "user is already over quota" case.
Timo Sirainen [Wed, 2 Jul 2014 17:36:49 +0000 (20:36 +0300)] 
quota: Fixed quota_transaction_is_over() to handle "user is already over quota" case.
If size=0 we didn't return failure. This change also fixes various potential
integer overflows in the check. Added unit test for the function.

11 years agoquota: Moved some functions to quota-util.c
Timo Sirainen [Wed, 2 Jul 2014 17:34:43 +0000 (20:34 +0300)] 
quota: Moved some functions to quota-util.c

11 years agolib: Added UINT64_SUM_OVERFLOWS()
Timo Sirainen [Wed, 2 Jul 2014 17:13:35 +0000 (20:13 +0300)] 
lib: Added UINT64_SUM_OVERFLOWS()
Maybe the unit tests are kind of unnecessary since the macro is so simple,
but at least it's now a well tested simple macro :)

11 years agopop3: pop3-commands - harden integer parsers against integer overflow
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
pop3: pop3-commands - harden integer parsers against integer overflow
In get_msgnum(), the invalid input "4772185884" (2^32*10/9) would be
parsed as being valid.

In get_size(), the invalid input "204963823041217240178" (2^64*10/9)
would be parsed as being valid.

We have helpers now, so use them.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: strnum - add permissive str_parse_uint() helper
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: strnum - add permissive str_parse_uint() helper
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: uri-util - hardern uri_parse_dec_octet() against overflow
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: uri-util - hardern uri_parse_dec_octet() against overflow
Invalid input 284 (2^8*10/9) is incorrectly parsed as valid.
28 * 10 + 4 = 284 == 28 (mod 2^8), so the wrap detection fails.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-http: test-http-url - add some tricky invalid numeric hostname URLs
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib-http: test-http-url - add some tricky invalid numeric hostname URLs
Try to get the numeric octet parser to fail. The RFCs specify that we should
fall back onto parsing them as domain names instead, and hence the unexpected
legitimacy of out-of-range numbers.

NOTE: This causes make check to report the following error:
http url valid [11]: http_url_parse(http://127.0.0.284/this/also/reverts/to/DNS)  : ok
test-http-url.c:328: Assert failed: urlp->have_host_ip == urlt->have_host_ip
http url valid [11] .................................................. : FAILED

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: uri-util - harden uri_parse_port against overflow
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: uri-util - harden uri_parse_port against overflow
The invalid input 72817 (2^16*10/9) is parsed as a valid value.
7281 * 10 + 7 = 72817 == 7281 (mod 2^16), so the prev check fails.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-http: test-http-url - make port number test cases harder
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib-http: test-http-url - make port number test cases harder
Exploit common parser weakeneses - out by one, and overflow detection failure.

NOTE: causes make check to fail with the following error:
http url invalid [13]: parse http://example.com:72817/index.html ..... : FAILED
http url invalid [13] ................................................ : FAILED

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agoimap: harden read_uoff_t() against overflow
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
imap: harden read_uoff_t() against overflow
Invalid strings like "20496382304121724029" (2^64*10/9) can be parsed
as valid. Use the new helper.

Change in error behaviour - previously overflows, if they were detected,
caused *p to point to the digit causing the overflow. Now it's undefined.
Current clients don't care about this difference, they just bail.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: strnum - add a permissive uoff_t parser
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: strnum - add a permissive uoff_t parser
Functions like these are so cookie-cutter, we may as well use a macro.
Note that signed helpers, if they ever appear, will need more care.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-strnum - tests for the new partial-string parser
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: test-strnum - tests for the new partial-string parser
We can simplify the main tests by always testing whether an appended
non-digit causes parsing to fail at the same time that we test it doesn't
fail with the new more permissive helpers.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: strnum - add permissive partial-string integer parser
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: strnum - add permissive partial-string integer parser
Not all strings we want to parse are already strtok'ed into separate pieces.
Therefore add helpers which will read the integer, and return a pointer
past the parsed integer.

The previous helpers can be considered a special case which just follows up
with a check that the '\0' has been reached.

Showing a preference for const pointers generally, this does not try to
mimic the non-const interface of strto{l,ul,ll,ull}().

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: number parsing simplification and hardenning
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib-imap: number parsing simplification and hardenning
The invalid string "4772185884" (2^32*10/9) will be misparsed as being valid.
In uint32_t's, 477218588 * 10 + 4 = 477218588
Many large ranges have this issue, 477218588x-858993459x, 954437176x-...

We have helper functions - use them.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: strnum - harden str_to_uintmax against overflows
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: strnum - harden str_to_uintmax against overflows
The invalid number "20496382304121724020" (2^64*10/9) will be parsed as valid.
2049638230412172402 * 10 does not noticably wrap, it becomes 2049638230412172404

Do not perform operations which might wrap, and then try to detect the issue,
just compare with the known fixed bounds before doing the multiplication.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-lib - add unit tests for str_to_*() helpers
Phil Carmody [Wed, 2 Jul 2014 15:21:24 +0000 (18:21 +0300)] 
lib: test-lib - add unit tests for str_to_*() helpers
This doesn't test all the helpers, but ensures both signed and unsigned
are tested, as are 32-bit and 64-bit cases. All the other helpers fall
back onto using one of those cases. Unless uintmax_t is larger than 64
bits, in which case this needs a revisit.

NOTE: This causes the following make check errors:
test-strnum.c:35: Assert(#7) failed: ret == u64tests[i].ret
test-strnum.c:35: Assert(#10) failed: ret == u64tests[i].ret
test-strnum.c:37: Assert(#10) failed: val == u64tests[i].val
str_to_uint64 ........................................................ : FAILED

Corresponding to test cases:
[7] = INVALID(18446744073709551616),
This does not wrap-past-0 (become smaller) on multiply, but wraps-past-0 on addition.
[10]= INVALID(20496382304121724020),
This wraps-past-n (becomes larger) on multiply.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-var-expand - use test_assert_idx() inside loops
Phil Carmody [Wed, 2 Jul 2014 15:21:23 +0000 (18:21 +0300)] 
lib: test-var-expand - use test_assert_idx() inside loops
It helps narrow down which test has failed.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-http: Updated comments to RFC7230/RFC7231.
Stephan Bosch [Tue, 1 Jul 2014 21:10:16 +0000 (00:10 +0300)] 
lib-http: Updated comments to RFC7230/RFC7231.

11 years agolib-http: Fixed bug in parsing of quoted string with escape sequences.
Stephan Bosch [Tue, 1 Jul 2014 20:24:08 +0000 (23:24 +0300)] 
lib-http: Fixed bug in parsing of quoted string with escape sequences.

11 years agodoveadm fs delete: Added -n to usage text.
Timo Sirainen [Tue, 1 Jul 2014 13:04:20 +0000 (16:04 +0300)] 
doveadm fs delete: Added -n to usage text.

11 years agolib-http: Added http_client_request_get_target()
Timo Sirainen [Mon, 30 Jun 2014 21:10:21 +0000 (00:10 +0300)] 
lib-http: Added http_client_request_get_target()
This can be useful in error message logging without having to duplicate the
string.

11 years agofts-tika: Hiden "Unsupported Media Type" errors. Log HTTP status code on errors.
Timo Sirainen [Mon, 30 Jun 2014 14:25:02 +0000 (17:25 +0300)] 
fts-tika: Hiden "Unsupported Media Type" errors. Log HTTP status code on errors.

11 years agofts-tika: Fixed crash if Tika returned 200 reply without payload.
Timo Sirainen [Mon, 30 Jun 2014 13:41:32 +0000 (16:41 +0300)] 
fts-tika: Fixed crash if Tika returned 200 reply without payload.

11 years agolib-storage: Shrink "mailbox is being deleted" timeout from 5 mins to 30 secs.
Timo Sirainen [Mon, 30 Jun 2014 11:35:32 +0000 (14:35 +0300)] 
lib-storage: Shrink "mailbox is being deleted" timeout from 5 mins to 30 secs.
Even 30s may be too much since normally a few seconds would be enough, but
keep it high enough just in case.

11 years agolib-storage: When deleting mailbox, finish the expunges before marking mailbox deleted.
Timo Sirainen [Mon, 30 Jun 2014 11:34:00 +0000 (14:34 +0300)] 
lib-storage: When deleting mailbox, finish the expunges before marking mailbox deleted.
This decreases the amount of time the mailbox is visible but not accessible.

11 years agolib-storage: mailbox_delete() now handled "mailbox is being deleted" explicitly.
Timo Sirainen [Mon, 30 Jun 2014 11:31:47 +0000 (14:31 +0300)] 
lib-storage: mailbox_delete() now handled "mailbox is being deleted" explicitly.
Earlier we just treated it as \NoSelect mailbox and failed later.

11 years agolib-storage: Added index_storage_mailbox_delete_pre/post().
Timo Sirainen [Mon, 30 Jun 2014 11:30:43 +0000 (14:30 +0300)] 
lib-storage: Added index_storage_mailbox_delete_pre/post().
This avoids reimplementing the whole index_storage_mailbox_delete() for
storage backends that need to do more work in the middle.

11 years agoimap: If we disconnect client because mailbox is inconsistent, send the error message...
Timo Sirainen [Mon, 30 Jun 2014 11:29:26 +0000 (14:29 +0300)] 
imap: If we disconnect client because mailbox is inconsistent, send the error message before BYE.

11 years agoimap: Don't disconnect due to inconsistent mailbox unless the mailbox is the selected...
Timo Sirainen [Mon, 30 Jun 2014 11:28:31 +0000 (14:28 +0300)] 
imap: Don't disconnect due to inconsistent mailbox unless the mailbox is the selected mailbox.

11 years agoimap-url: Fixed handling of ipath-empty syntax (basically empty relative URLs).
Stephan Bosch [Fri, 27 Jun 2014 14:39:52 +0000 (17:39 +0300)] 
imap-url: Fixed handling of ipath-empty syntax (basically empty relative URLs).
This also normalizes Mailbox/ to Mailbox.
Initial indication reported by Coverity.

11 years agoauth: Added assert to make sure sysconf() returns what we expect.
Timo Sirainen [Fri, 27 Jun 2014 14:37:56 +0000 (17:37 +0300)] 
auth: Added assert to make sure sysconf() returns what we expect.
userdb nss shouldn't even be used though. So this is mainly to silence
Coverity.

11 years agolib: istream-concat read() returned -2 too early.
Timo Sirainen [Fri, 27 Jun 2014 13:29:18 +0000 (16:29 +0300)] 
lib: istream-concat read() returned -2 too early.

11 years agolib: rand - force reseeding with known seed from environment
Phil Carmody [Fri, 27 Jun 2014 13:20:25 +0000 (16:20 +0300)] 
lib: rand - force reseeding with known seed from environment
Use DOVECOT_SRAND=12345 as an environmental variable to force seeding
to that number.

The logic behind the logging is that the subsequent calls will almost
certainly be from random_fill_weak() which expects to have been seeded
from a CSPRNG - not a constant! Having this environmental variable set
in a production system that expects CSPRNG seeding should be flagging
diagnostics.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: remove unwanted srand()s from unit tests
Phil Carmody [Fri, 27 Jun 2014 13:17:50 +0000 (16:17 +0300)] 
lib: remove unwanted srand()s from unit tests
We'll get better coverage without them.

Note: this change causes the following test case failure occasionally:
test-istream-concat.c:88: Assert failed: size >= TEST_MAX_BUFFER_SIZE
istream concat random ................................................ : FAILED
test: random seed #1 was 1403027537

(The seed may vary, obviously.)

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: use the new srand() tracking helpers to aid debugging
Phil Carmody [Fri, 27 Jun 2014 13:17:07 +0000 (16:17 +0300)] 
lib-test: use the new srand() tracking helpers to aid debugging
We can only be sure we know the entirity of the stream of numbers returned
by rand if rand_set_seed has been called precisely once, as after that we
can't be sure when it was called a 2nd or further time. However, at least
we can know that that has happened. (Likewise, any calls to srand() will
disturb the flow.)

Most unit test cases should be simple enough that there should be only one
seeding.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: use new srand() wrapper in lib
Phil Carmody [Fri, 27 Jun 2014 13:16:16 +0000 (16:16 +0300)] 
lib: use new srand() wrapper in lib
Of course, multiple seeding calls make it harder to know exactly
what numbers have been generated. But this is better than nothing.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: add rand helper library
Phil Carmody [Fri, 27 Jun 2014 13:15:24 +0000 (16:15 +0300)] 
lib: add rand helper library
Initially, just wrap srand() so that we can find out what the last-used
seed was. In situations where srand() is called only once (via this helper)
this lets us reproduce exactly the same stream of random data again in
order to reproduce rare crashes.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: two quite literally random little cleanups
Phil Carmody [Fri, 27 Jun 2014 13:13:37 +0000 (16:13 +0300)] 
lib: two quite literally random little cleanups
file-dotlock.c does not use randgen.h, remove the #include
test-buffer.c random() has been used rather than rand()

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: make printf_format_fix safer against shadowed %m behaviour
Phil Carmody [Fri, 27 Jun 2014 13:13:09 +0000 (16:13 +0300)] 
lib: make printf_format_fix safer against shadowed %m behaviour
If there's a %m followed by a %n or %m, then the %n or %m won't be seen.
For %m, that's mostly harmless, but for %n it's potentially kaboom.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test printf_format_fix()
Phil Carmody [Fri, 27 Jun 2014 13:12:40 +0000 (16:12 +0300)] 
lib: test printf_format_fix()
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-istream-concat - early abort test loop on failure
Phil Carmody [Fri, 27 Jun 2014 13:11:40 +0000 (16:11 +0300)] 
lib: test-istream-concat - early abort test loop on failure
No point in continuing past the first failure.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: Enable looped tests to abort early on first failure
Phil Carmody [Fri, 27 Jun 2014 13:10:27 +0000 (16:10 +0300)] 
lib-test: Enable looped tests to abort early on first failure
Give them the ability to query the current failure state.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolmtp: Reduce corking so we get command replies more quickly even if they are pipelined.
Timo Sirainen [Fri, 27 Jun 2014 11:23:46 +0000 (14:23 +0300)] 
lmtp: Reduce corking so we get command replies more quickly even if they are pipelined.
This may help avoid some LMTP client timeouts.

11 years agolmtp proxy: Make sure DATA stream size doesn't change unexpectedly.
Timo Sirainen [Fri, 27 Jun 2014 11:06:56 +0000 (14:06 +0300)] 
lmtp proxy: Make sure DATA stream size doesn't change unexpectedly.

11 years agolib-lda: If DATA input stream read fails, return error instead of truncating the...
Timo Sirainen [Fri, 27 Jun 2014 11:06:08 +0000 (14:06 +0300)] 
lib-lda: If DATA input stream read fails, return error instead of truncating the mail.

11 years agolib: Moved rawlog dir stat()s to iostream_rawlog_create() internally.
Timo Sirainen [Thu, 26 Jun 2014 17:48:13 +0000 (20:48 +0300)] 
lib: Moved rawlog dir stat()s to iostream_rawlog_create() internally.
This is required to allow TCP rawlogs to actually work.

11 years agolib: iostream-rawlog now supports TCP target with "tcp:host:port" as the path.
Timo Sirainen [Thu, 26 Jun 2014 17:46:21 +0000 (20:46 +0300)] 
lib: iostream-rawlog now supports TCP target with "tcp:host:port" as the path.
We'll use blocking sockets, so a slow rawlog server causes performance
problems also for Dovecot while it's waiting on rawlog writes.

11 years agolib-storage: BODYSTRUCTURE parsing failures weren't treated correctly.
Timo Sirainen [Thu, 26 Jun 2014 14:50:57 +0000 (17:50 +0300)] 
lib-storage: BODYSTRUCTURE parsing failures weren't treated correctly.
We still assumed that the parsing succeeded and assert-crashed later or
maybe returned invalid results. (This could have happened only if there was
a problem reading the mail stream.)