]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
12 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.

12 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.

12 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.

12 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.

12 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.

12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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.

12 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.

12 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.

12 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.

12 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.

12 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.)

12 years agodsync: Fixed infinite looping on error condition.
Timo Sirainen [Thu, 26 Jun 2014 14:27:31 +0000 (17:27 +0300)] 
dsync: Fixed infinite looping on error condition.

12 years agodbox: mail_get_special() may have returned MAIL_FETCH_POP3_ORDER allocated from data...
Timo Sirainen [Thu, 26 Jun 2014 14:27:22 +0000 (17:27 +0300)] 
dbox: mail_get_special() may have returned MAIL_FETCH_POP3_ORDER allocated from data stack.
Although this seems to have worked for now, it shouldn't have been done.

12 years agolib-test: Fixed "Trying to allocate 0 bytes" assert-crash caused by recent test-istre...
Timo Sirainen [Wed, 25 Jun 2014 13:16:02 +0000 (16:16 +0300)] 
lib-test: Fixed "Trying to allocate 0 bytes" assert-crash caused by recent test-istream changes.

12 years agolib: fd_recv() no longer checks for msghdr.msg_controllen
Timo Sirainen [Fri, 20 Jun 2014 09:18:32 +0000 (12:18 +0300)] 
lib: fd_recv() no longer checks for msghdr.msg_controllen
It doesn't work at least in OpenBSD and Tru64, and apparently it shouldn't
really be needed anyway, so don't bother with it. We'll still keep checking
the cmsghdr since that appears to work everywhere now.

12 years agombox: istream-tee wasn't being used as expected with the new changes, causing crashes...
Timo Sirainen [Thu, 19 Jun 2014 14:16:24 +0000 (17:16 +0300)] 
mbox: istream-tee wasn't being used as expected with the new changes, causing crashes/hangs.
After wondering about this for a while I decided this was the only fully
reliable way of doing this. Although it would have been possible to change
the istream-tee code to support this:

child1 and child2 are tee-istream children:
 - i_stream_read(child1)
 - i_stream_read(child2)
 - i_stream_get_data(child1)

Because reading from the parent istream-tee updates all of its childrens'
buffer, there's no big problem (other than access_counter currently messing
up). But if one of the children weren't a direct child of tee-istream, but
there was a wrapper istream, the wrapper's buffer wouldn't have been updated
by the istream-tee read. So rather than spending time figuring out to fix
the access_counter it's probably better to have it clearly fail as the use
case can't be fully safe anyway.

12 years agolmtp: Create all proxy DATA streams before reading from them.
Timo Sirainen [Thu, 19 Jun 2014 12:50:40 +0000 (15:50 +0300)] 
lmtp: Create all proxy DATA streams before reading from them.
I'm not sure if this actually fixes anything or not, but it's still safer
to do it this way.

12 years agolib: i_stream_read_copy_from_parent() now directly updates the access counter
Timo Sirainen [Thu, 19 Jun 2014 12:15:24 +0000 (15:15 +0300)] 
lib: i_stream_read_copy_from_parent() now directly updates the access counter
This fixes a bug in istream-mail where it called i_stream_get_data() after
it and reset the stream's skip/pos.

12 years agolib: i_stream_get_data() should also reset eof=FALSE if it truncates the output.
Timo Sirainen [Thu, 19 Jun 2014 11:58:26 +0000 (14:58 +0300)] 
lib: i_stream_get_data() should also reset eof=FALSE if it truncates the output.

12 years agolib-mail: Fixed istream-dot unit test to work with the istream-test changes.
Timo Sirainen [Thu, 19 Jun 2014 11:34:54 +0000 (14:34 +0300)] 
lib-mail: Fixed istream-dot unit test to work with the istream-test changes.

12 years agoCompiler warning fix
Timo Sirainen [Thu, 19 Jun 2014 11:02:56 +0000 (14:02 +0300)] 
Compiler warning fix

12 years agolib: If two istreams share one parent, i_stream_get_data() may have returned corrupte...
Timo Sirainen [Thu, 19 Jun 2014 10:52:36 +0000 (13:52 +0300)] 
lib: If two istreams share one parent, i_stream_get_data() may have returned corrupted data to another.
This happened only for istreams that used parent's buffer directly instead
of having their own buffer. For now at least we've solved this by truncating
the other stream's buffer so it needs to be read again. Hopefully this is
good enough.

Added also unit test to check this functionality.

12 years agolib-test: Improved test-istream to catch more bugs
Timo Sirainen [Thu, 19 Jun 2014 09:38:11 +0000 (12:38 +0300)] 
lib-test: Improved test-istream to catch more bugs

12 years agolib: Fixed read buffer overflow in istream-base64-decoder error handling
Timo Sirainen [Thu, 19 Jun 2014 09:32:45 +0000 (12:32 +0300)] 
lib: Fixed read buffer overflow in istream-base64-decoder error handling

12 years agolib: Fixed potential read buffer overflow in JSON parser.
Timo Sirainen [Thu, 19 Jun 2014 09:31:55 +0000 (12:31 +0300)] 
lib: Fixed potential read buffer overflow in JSON parser.

12 years agologin proxy: Added login_source_ips setting.
Timo Sirainen [Mon, 16 Jun 2014 16:52:11 +0000 (19:52 +0300)] 
login proxy: Added login_source_ips setting.
The setting contains a list of IPs/hosts. The setting may be prefixed with
"?" character to indicate that only those IPs should be used that exist in
the current server (allowing the same config to be shared by multiple
servers).

The IPs are used round robin as the source IP address when proxy creates TCP
connections. This becomes useful when there are a ton of connections from
the proxy to the same destination IP, because TCP ports run out after ~64k
connections.

12 years agologin proxy: If passdb returns "source_ip" extra field, use it for outgoing connections.
Timo Sirainen [Mon, 16 Jun 2014 16:21:36 +0000 (19:21 +0300)] 
login proxy: If passdb returns "source_ip" extra field, use it for outgoing connections.

12 years agolib: Use __attribute__((returns_nonnull)) for the common memory/string functions.
Timo Sirainen [Mon, 16 Jun 2014 15:01:58 +0000 (18:01 +0300)] 
lib: Use __attribute__((returns_nonnull)) for the common memory/string functions.
Also added a couple of missing ATTR_MALLOCs.

12 years agolib: Changed mempool.h to use inline functions instead of macros.
Timo Sirainen [Mon, 16 Jun 2014 14:40:51 +0000 (17:40 +0300)] 
lib: Changed mempool.h to use inline functions instead of macros.
This way we can also mark p_malloc() with ATTR_MALLOC.

12 years agodoveadm who: Don't crash if server happens to send broken input (second try).
Timo Sirainen [Mon, 16 Jun 2014 13:27:12 +0000 (16:27 +0300)] 
doveadm who: Don't crash if server happens to send broken input (second try).
Found by Coverity

12 years agodoveadm dump: Avoid crashes with corrupted log files
Timo Sirainen [Mon, 16 Jun 2014 13:26:09 +0000 (16:26 +0300)] 
doveadm dump: Avoid crashes with corrupted log files

12 years agodoveadm dump log: Fixed potential crash when log header size was corrupted.
Timo Sirainen [Mon, 16 Jun 2014 12:47:12 +0000 (15:47 +0300)] 
doveadm dump log: Fixed potential crash when log header size was corrupted.

12 years agoAdded (void) prefix for ignoring return values we don't care about.
Timo Sirainen [Mon, 16 Jun 2014 12:42:39 +0000 (15:42 +0300)] 
Added (void) prefix for ignoring return values we don't care about.
Hopefully this quiets down Coverity warnings also of them?

12 years agoCheck for syscall errors that are quite unlikely to happen.
Timo Sirainen [Mon, 16 Jun 2014 12:41:52 +0000 (15:41 +0300)] 
Check for syscall errors that are quite unlikely to happen.
Flagged by Coverity.

12 years agoxml2text: Check for read()/write() failures and exit if they fail.
Timo Sirainen [Mon, 16 Jun 2014 12:35:07 +0000 (15:35 +0300)] 
xml2text: Check for read()/write() failures and exit if they fail.

12 years agolmtp: Proxying now logs successful and failed deliveries after DATA.
Timo Sirainen [Mon, 16 Jun 2014 10:12:40 +0000 (13:12 +0300)] 
lmtp: Proxying now logs successful and failed deliveries after DATA.

12 years agolmtp: Removed some unnecessary code
Timo Sirainen [Mon, 16 Jun 2014 10:03:31 +0000 (13:03 +0300)] 
lmtp: Removed some unnecessary code

12 years agoauth: Fixed wrong assert added by recent commit.
Timo Sirainen [Sun, 15 Jun 2014 08:03:32 +0000 (11:03 +0300)] 
auth: Fixed wrong assert added by recent commit.

12 years agotrivial variable-non-use fixes
Phil Carmody [Sat, 14 Jun 2014 08:58:57 +0000 (11:58 +0300)] 
trivial variable-non-use fixes
Flagged by coverity. In one, as we're printing an error message, we
can actually put the string to use, which might aid debugging. In
the other, the variable can just be killed.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agofts-lucene: Fix SnowballAnalyzer constructors
Phil Carmody [Fri, 13 Jun 2014 13:12:27 +0000 (16:12 +0300)] 
fts-lucene: Fix SnowballAnalyzer constructors
Coverity found the uninitialised pointers in the latter constructor (which
is never used - kill it?). In comparing the other constructor, the lack of
strdup() jumped out at me.

In fixing them both I migrated them to actual C++ initialisers, rather than
dumb assignments to uninitialised members. Also migrated to dovecot's i_*
functions. Also fixed indentation for the 3 functions touched.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agoAdded several asserts to make sure duplicates aren't inserted into hash table.
Timo Sirainen [Fri, 13 Jun 2014 12:14:44 +0000 (15:14 +0300)] 
Added several asserts to make sure duplicates aren't inserted into hash table.
The previous commit hopefully fixed the problem causing auth and login
processes to sometimes die with "key not found from hash" error, but if not
maybe one of these will catch it.

12 years agolib-master: Fixed caching settings where both local_name and local_ip was specified.
Timo Sirainen [Fri, 13 Jun 2014 12:13:26 +0000 (15:13 +0300)] 
lib-master: Fixed caching settings where both local_name and local_ip was specified.
Since cache_find() didn't use local_ip for a lookup when local_name existed,
cache_add() shouldn't add both of them either, otherwise it could be
inserting duplicate values to the cache hash and cause crashes.

12 years agoMake sure we don't shift signed integers left by 24. They should be unsigned.
Timo Sirainen [Fri, 13 Jun 2014 08:35:40 +0000 (11:35 +0300)] 
Make sure we don't shift signed integers left by 24. They should be unsigned.

12 years agodbox: Fixed potential infinite looping when scanning a broken dbox file.
Timo Sirainen [Fri, 13 Jun 2014 08:21:07 +0000 (11:21 +0300)] 
dbox: Fixed potential infinite looping when scanning a broken dbox file.

12 years agoauth: Fixed handling userdb_userdb_import passdb extra field.
Timo Sirainen [Fri, 13 Jun 2014 07:25:22 +0000 (10:25 +0300)] 
auth: Fixed handling userdb_userdb_import passdb extra field.
Looks like some hg merging went wrong.
Found by Coverity

12 years agolib-http: Removed unnecessary for loop.
Timo Sirainen [Fri, 13 Jun 2014 07:22:49 +0000 (10:22 +0300)] 
lib-http: Removed unnecessary for loop.
Found by Coverity

12 years agodbox: Added asserts to dbox file fixing to make sure it doesn't go to infinite loop.
Timo Sirainen [Fri, 13 Jun 2014 00:09:26 +0000 (03:09 +0300)] 
dbox: Added asserts to dbox file fixing to make sure it doesn't go to infinite loop.
There apparently is a bug in here that will trigger this assert.

12 years agoimap, pop3: Remove the client from clients-list at the very end of the destroy function.
Timo Sirainen [Thu, 12 Jun 2014 23:54:21 +0000 (02:54 +0300)] 
imap, pop3: Remove the client from clients-list at the very end of the destroy function.
Especially with imap code the process title could have been refreshed too
early.

12 years agoCompiler warning fix
Timo Sirainen [Thu, 12 Jun 2014 23:34:19 +0000 (02:34 +0300)] 
Compiler warning fix

12 years agoUse the new [io]_stream_create_fd_*autoclose() functions wherever possible.
Timo Sirainen [Thu, 12 Jun 2014 23:19:15 +0000 (02:19 +0300)] 
Use the new [io]_stream_create_fd_*autoclose() functions wherever possible.

12 years agolib: Added [io]_stream_create_fd_*autoclose()
Timo Sirainen [Thu, 12 Jun 2014 23:18:53 +0000 (02:18 +0300)] 
lib: Added [io]_stream_create_fd_*autoclose()
These make it clearer that the fd parameter will be closed automatically
when the stream is closed.

Eventually (in v2.3) we'll want to get rid of the autoclose boolean
parameter in [io]_stream_create_fd().

12 years agodoveadm stats top: Fixed double-close()ing stats connection
Timo Sirainen [Thu, 12 Jun 2014 23:04:12 +0000 (02:04 +0300)] 
doveadm stats top: Fixed double-close()ing stats connection

12 years agodirector-test: Fixed double-close() on admin connection deinit
Timo Sirainen [Thu, 12 Jun 2014 23:01:55 +0000 (02:01 +0300)] 
director-test: Fixed double-close() on admin connection deinit

12 years agoAdded various asserts to try to silence Coverity false positives.
Timo Sirainen [Thu, 12 Jun 2014 22:57:04 +0000 (01:57 +0300)] 
Added various asserts to try to silence Coverity false positives.

12 years agolib-mail: message_parser_parse_next_block() now fully clears block_r to be safe case.
Timo Sirainen [Thu, 12 Jun 2014 22:52:13 +0000 (01:52 +0300)] 
lib-mail: message_parser_parse_next_block() now fully clears block_r to be safe case.
I'm not away of this hitting any bugs, but better to be safe.

12 years agoAdded "fall through" comments to switch statements where break is intentionally missing.
Timo Sirainen [Thu, 12 Jun 2014 22:35:13 +0000 (01:35 +0300)] 
Added "fall through" comments to switch statements where break is intentionally missing.
This should make Coverity quiet about these..

12 years agolib-storage: Fixed parsing corrupted mailbox list index header.
Timo Sirainen [Thu, 12 Jun 2014 22:30:14 +0000 (01:30 +0300)] 
lib-storage: Fixed parsing corrupted mailbox list index header.
Duplicate IDs should have caused an error instead of being silently ignored.
Found by Coverity

12 years agoimap-urlauth: Fatal failure error handling wasn't done correctly.
Timo Sirainen [Thu, 12 Jun 2014 22:26:14 +0000 (01:26 +0300)] 
imap-urlauth: Fatal failure error handling wasn't done correctly.
Found by Coverity

12 years agoreplication plugin: Synchronous notification timeout error wasn't logged as intended.
Timo Sirainen [Thu, 12 Jun 2014 22:22:23 +0000 (01:22 +0300)] 
replication plugin: Synchronous notification timeout error wasn't logged as intended.
Found by Coverity

12 years agolib-otp: OTP_MAX_WORD_LEN wasn't actually enforced, any word lengths could have been...
Timo Sirainen [Thu, 12 Jun 2014 22:20:25 +0000 (01:20 +0300)] 
lib-otp: OTP_MAX_WORD_LEN wasn't actually enforced, any word lengths could have been used.
Doesn't look like this could have caused any real problems.
Found by Coverity

12 years agofts: Improved doveadm fts dump for corrupted expunge log
Timo Sirainen [Thu, 12 Jun 2014 22:11:24 +0000 (01:11 +0300)] 
fts: Improved doveadm fts dump for corrupted expunge log
Although we may still be trying to allocate up to 2 GB of memory, but at
least no more than that now.
Found by Coverity

12 years agolib: Fixed file_dotlock_replace(flags=DOTLOCK_REPLACE_FLAG_VERIFY_OWNER|DOTLOCK_REPLA...
Timo Sirainen [Thu, 12 Jun 2014 22:02:48 +0000 (01:02 +0300)] 
lib: Fixed file_dotlock_replace(flags=DOTLOCK_REPLACE_FLAG_VERIFY_OWNER|DOTLOCK_REPLACE_FLAG_DONT_CLOSE_FD)
The verification check failed because fd was already set to -1 by that time.
Found by Coverity

12 years agodirector: Fixed crash if master_user_separator is set, but we didn't do a proxy lookup.
Timo Sirainen [Thu, 12 Jun 2014 21:57:06 +0000 (00:57 +0300)] 
director: Fixed crash if master_user_separator is set, but we didn't do a proxy lookup.
Found by Coverity

12 years agoimapc: Avoid crashing if server happens to send invalid resp-text-codes.
Timo Sirainen [Thu, 12 Jun 2014 21:51:44 +0000 (00:51 +0300)] 
imapc: Avoid crashing if server happens to send invalid resp-text-codes.
If [KEY VALUE] is missing the VALUE, just set it to "" instead of NULL.
Found by Coverity

12 years agofts: Minor code cleanup: Don't increment NULL pointer.
Timo Sirainen [Thu, 12 Jun 2014 21:46:34 +0000 (00:46 +0300)] 
fts: Minor code cleanup: Don't increment NULL pointer.

12 years agoRemoved pointless NULL checks.
Timo Sirainen [Thu, 12 Jun 2014 21:45:43 +0000 (00:45 +0300)] 
Removed pointless NULL checks.
Found by Coverity

12 years agoauth: Invalid userdb passwd-file and userdb templates may have caused crashes.
Timo Sirainen [Thu, 12 Jun 2014 21:30:27 +0000 (00:30 +0300)] 
auth: Invalid userdb passwd-file and userdb templates may have caused crashes.
Using just "key" parameter instead of "key=value" usually worked, but for
some keys the code assumed that there was a value and it dereferenced NULL.
We'll solve this by just using value="" instead of value=NULL.
Found by Coverity

12 years agoauth: passdb/userdb dict settings file parsing didn't handle errors correctly.
Timo Sirainen [Thu, 12 Jun 2014 21:15:47 +0000 (00:15 +0300)] 
auth: passdb/userdb dict settings file parsing didn't handle errors correctly.
Found by Coverity

12 years agolib: Changed net_geterror() to return errno instead of -1 if getsockopt() fails.
Timo Sirainen [Thu, 12 Jun 2014 21:09:23 +0000 (00:09 +0300)] 
lib: Changed net_geterror() to return errno instead of -1 if getsockopt() fails.
None of the callers were actually checking for the -1 error value but
instead just passing it to strerror(). Since this error should just about
never happen it's better to just return a usable return value than try to
remember to handle errors that can't normally even happen.
Found by Coverity

12 years agodoveadm sis deduplicate: Error handling fix if open() fails.
Timo Sirainen [Thu, 12 Jun 2014 21:05:16 +0000 (00:05 +0300)] 
doveadm sis deduplicate: Error handling fix if open() fails.
Found by Coverity.

12 years agolib: Added (void) prefixes to some setsockopt() calls which we don't care if they...
Timo Sirainen [Thu, 12 Jun 2014 21:03:11 +0000 (00:03 +0300)] 
lib: Added (void) prefixes to some setsockopt() calls which we don't care if they fail.

12 years agodsync: Fixed potential crash when debug logging was enabled.
Timo Sirainen [Thu, 12 Jun 2014 21:00:31 +0000 (00:00 +0300)] 
dsync: Fixed potential crash when debug logging was enabled.
Found by Coverity.

12 years agombox: X-Delivery-ID: and X-IMAP: headers weren't dropped from incoming mails.
Timo Sirainen [Thu, 12 Jun 2014 20:51:28 +0000 (23:51 +0300)] 
mbox: X-Delivery-ID: and X-IMAP: headers weren't dropped from incoming mails.
Because of a missing comma.. Found by Coverity.

12 years agodoveadm who: Don't crash if server happens to send broken input.
Timo Sirainen [Thu, 12 Jun 2014 20:47:55 +0000 (23:47 +0300)] 
doveadm who: Don't crash if server happens to send broken input.
Found by Coverity.

12 years agoconfigure: Don't actually run the test to see if inotify works.
Timo Sirainen [Thu, 12 Jun 2014 20:16:40 +0000 (23:16 +0300)] 
configure: Don't actually run the test to see if inotify works.
It's definitely no longer needed in modern Linux systems and the test itself
can also unintentionally fail sometimes.

12 years agolib: Changed hash_table_remove() "key not found" panic to be in a macro itself.
Timo Sirainen [Thu, 12 Jun 2014 09:51:34 +0000 (12:51 +0300)] 
lib: Changed hash_table_remove() "key not found" panic to be in a macro itself.
This makes it much easier to find out where such crashes are coming from.
Since this breaks the ABI in such a many places the ABI version number was
increased immediately..

12 years agolib: test-bits - fix nearest_power for 32-bit size_t
Phil Carmody [Tue, 10 Jun 2014 15:49:45 +0000 (17:49 +0200)] 
lib: test-bits - fix nearest_power for 32-bit size_t
The test blindly went up to b=63, and the function correctly asserted.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agorawlog: Buffer writing to rawlog files to improve performance.
Timo Sirainen [Tue, 10 Jun 2014 14:40:46 +0000 (16:40 +0200)] 
rawlog: Buffer writing to rawlog files to improve performance.

12 years agolib-fs: Fixed crash in fs-sis if hard linking failed.
Timo Sirainen [Mon, 9 Jun 2014 20:08:18 +0000 (23:08 +0300)] 
lib-fs: Fixed crash in fs-sis if hard linking failed.
(For example because there were too many hard links.)
Pointed out by Pavel Stano

12 years agolib: fix numpack overflow checking
Phil Carmody [Mon, 9 Jun 2014 20:02:52 +0000 (23:02 +0300)] 
lib: fix numpack overflow checking
As on broken input, bits may grow without limit, so << bits becomes
Undefined Behaviour. Add a simple check to the while loop to prevent
this.

Also, the (presumably) final byte adds something to the bit length,
so include that in the tally. If we didn't get to a final byte due
to the above while() condition, then this extra addition does no harm

Now we can precisely check for overflow conditions. Note that 64 bits
is perfectly OK, only 65+ is an overflow.

Note - no longer moving *p if there was a decode error.

Expand the test suite to check for overflow cases. Also checked for
short-input cases too, while I was there.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agolib: unit tests for lib/bits
Phil Carmody [Mon, 9 Jun 2014 20:02:52 +0000 (23:02 +0300)] 
lib: unit tests for lib/bits
Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agolib-test: test_assert helper for loops
Phil Carmody [Mon, 9 Jun 2014 20:02:52 +0000 (23:02 +0300)] 
lib-test: test_assert helper for loops
If you're repeatedly testing the same expression in a loop, it's
good to know where you are in the loop. Add an additional parameter
for these cases.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agolib: bit twiddles
Phil Carmody [Mon, 9 Jun 2014 20:02:52 +0000 (23:02 +0300)] 
lib: bit twiddles
bits_requiredXX() gives the number of bits required to store an unsigned
integer. Here, XX is 8, 16, 32, 64, reperesenting the size of the operand.
It belongs in the same file as nearest_power(), which makes most sense
in a separate bit twiddles file. Universal enough to stay in lib.h by
inclusion.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agolib: Fix MEM_ALIGN to cope with huge allocations
Phil Carmody [Mon, 9 Jun 2014 19:59:59 +0000 (22:59 +0300)] 
lib: Fix MEM_ALIGN to cope with huge allocations
Attempting to allocate 2^32+1 bytes will look like it succeeds, as MEM_ALIGN
will set alloc_size = 8. The caller will then think it's got 4 gig to play
with.

e.g. t_malloc0 will wipe vast areas of memory before segfaulting, which might
include useful information we'd like in a corefile.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
12 years agolib-index: modseq -> {log file, offset} lookup often ignored dovecot.index.log.2
Timo Sirainen [Mon, 9 Jun 2014 19:53:16 +0000 (22:53 +0300)] 
lib-index: modseq -> {log file, offset} lookup often ignored dovecot.index.log.2
This caused the code to think that the modseq was too old and fall back into
slower sync.

So this change should fix the dsync "Modseq .. nom longer in transaction
log" warnings as well as improve IMAP QRESYNC efficiency.

12 years agolib: Added some kind of a unit test for hash table.
Timo Sirainen [Mon, 9 Jun 2014 15:15:51 +0000 (18:15 +0300)] 
lib: Added some kind of a unit test for hash table.
Just try out some insert+deletes randomly. Mainly I wrote this to check if
there is some obvious problem, but looks like not.

12 years agolib-ssl-iostream: Implement get_used_size() method.
Timo Sirainen [Mon, 9 Jun 2014 12:11:50 +0000 (15:11 +0300)] 
lib-ssl-iostream: Implement get_used_size() method.
Previously we were always returning that we didn't have anything buffered,
which could have caused huge memory usage (or malloc failures) with its
users (e.g. dsync).

12 years agologin-common: Fixed potential crash at client disconnect.
Timo Sirainen [Mon, 9 Jun 2014 10:41:59 +0000 (13:41 +0300)] 
login-common: Fixed potential crash at client disconnect.
Broken by recent change

12 years agologin-common: Fixed infinite loop in ssl proxy flushing.
Teemu Huovila [Mon, 9 Jun 2014 09:14:42 +0000 (12:14 +0300)] 
login-common: Fixed infinite loop in ssl proxy flushing.

12 years agologin proxy: Fixed connection hanging due to wrong ostream cork pairing
Timo Sirainen [Mon, 9 Jun 2014 09:12:58 +0000 (12:12 +0300)] 
login proxy: Fixed connection hanging due to wrong ostream cork pairing