]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
7 years agolib-http: server: Properly handle corrupt payload while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:14:39 +0000 (18:14 +0100)] 
lib-http: server: Properly handle corrupt payload while finishing a request.

The HTTP_REQUEST_PARSE_ERROR_BROKEN_REQUEST was not handled, causing an
assertion panic. This situation occurred when the chunked transfer encoding was
invalid.

7 years agolib-http: server: Properly handle payload stream errors while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:10:42 +0000 (18:10 +0100)] 
lib-http: server: Properly handle payload stream errors while finishing a request.

Errors from the (chunked) payload stream would cause assertion panics at that point.

7 years agolib-http: server: Allow resubmitting a response, as long as it is not sent yet.
Stephan Bosch [Tue, 20 Mar 2018 17:04:36 +0000 (18:04 +0100)] 
lib-http: server: Allow resubmitting a response, as long as it is not sent yet.

7 years agocassandra: Add proper log levels to logged messages
Timo Sirainen [Thu, 26 Apr 2018 18:07:31 +0000 (21:07 +0300)] 
cassandra: Add proper log levels to logged messages

If logging to "internal handler", i.e. to log process, write the log prefix
that includes the log level. This way Cassandra's trace/debug/info messages
won't end up in error log.

7 years agolib: Add i_failure_handler_is_internal()
Timo Sirainen [Thu, 26 Apr 2018 18:07:22 +0000 (21:07 +0300)] 
lib: Add i_failure_handler_is_internal()

7 years agolib-fs: fs-posix - Add accurate-mtime parameter
Timo Sirainen [Thu, 26 Apr 2018 16:38:55 +0000 (19:38 +0300)] 
lib-fs: fs-posix - Add accurate-mtime parameter

This is mainly useful for testing to find out whether one file was created
after another.

7 years agolib-fs: Update FS_METADATA_WRITE_FNAME comment
Timo Sirainen [Thu, 26 Apr 2018 15:23:54 +0000 (18:23 +0300)] 
lib-fs: Update FS_METADATA_WRITE_FNAME comment

7 years agolib-fs: fs-posix - FS_METADATA_WRITE_FNAME replaces the full path
Timo Sirainen [Thu, 26 Apr 2018 15:14:27 +0000 (18:14 +0300)] 
lib-fs: fs-posix - FS_METADATA_WRITE_FNAME replaces the full path

This is how all the other fs drivers work, although the macro name is a bit
confusing.

7 years agolib-fs: fs-metawrap - Pass FS_METADATA_WRITE_FNAME through to parent fs
Timo Sirainen [Thu, 26 Apr 2018 15:14:46 +0000 (18:14 +0300)] 
lib-fs: fs-metawrap - Pass FS_METADATA_WRITE_FNAME through to parent fs

fs-metawrap in the middle pervented the renaming from working.

7 years agolib-storage: Remove mail_attachment_detection_options=add-flags-on-fetch parsing
Timo Sirainen [Thu, 26 Apr 2018 13:42:40 +0000 (16:42 +0300)] 
lib-storage: Remove mail_attachment_detection_options=add-flags-on-fetch parsing

It wasn't actually used yet.

7 years agolib-storage: Fail if mail_attachment_detection_options has invalid options
Timo Sirainen [Thu, 26 Apr 2018 13:41:55 +0000 (16:41 +0300)] 
lib-storage: Fail if mail_attachment_detection_options has invalid options

7 years agolib-storage: Set $Has[No]Attachment earlier among other cached data
Timo Sirainen [Thu, 19 Apr 2018 13:38:22 +0000 (16:38 +0300)] 
lib-storage: Set $Has[No]Attachment earlier among other cached data

7 years agolib: Fix returning error from unlink_directory()
Timo Sirainen [Thu, 26 Apr 2018 23:39:10 +0000 (02:39 +0300)] 
lib: Fix returning error from unlink_directory()

On non-ENOENT errors it was returning 1 instead of -1.

7 years agolib-storage: Fix event leak when failing to create storage
Timo Sirainen [Thu, 26 Apr 2018 20:05:21 +0000 (23:05 +0300)] 
lib-storage: Fix event leak when failing to create storage

7 years agomdbox: Assume that empty uid maps found during sync are harmless
Josef 'Jeff' Sipek [Mon, 23 Apr 2018 22:15:51 +0000 (18:15 -0400)] 
mdbox: Assume that empty uid maps found during sync are harmless

Instead of failing the sync and causing index rebuild, just skip over
the empty uid maps.  Chances are that they these records came from
various plugins that create fake mails.

7 years agoman: Document doveadm mailbox cache commands
Aki Tuomi [Wed, 25 Apr 2018 07:56:04 +0000 (10:56 +0300)] 
man: Document doveadm mailbox cache commands

7 years agoplugins/old-stats: Remove restrict_access_set_dumpable calls from process_io_open().
Sergey Kitov [Thu, 26 Apr 2018 06:48:39 +0000 (09:48 +0300)] 
plugins/old-stats: Remove restrict_access_set_dumpable calls from process_io_open().

proc_io_fd is opened in preinit(), while process have root access, so
restrict_access_set_dumpable() calls are not needed.

7 years ago.gitignore: Ignore doc/man/doveadm-rebuild.1
Martti Rannanjärvi [Thu, 26 Apr 2018 10:18:01 +0000 (13:18 +0300)] 
.gitignore: Ignore doc/man/doveadm-rebuild.1

7 years agoglobal - migrate more complicated strncmp expressions to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:35:42 +0000 (15:35 +0200)] 
global - migrate more complicated strncmp expressions to str_begins

Simplify a bunch of verbose var=strlen(); strncmp(,,var) calls.
Fortunately, all of these examples use the length variable, so no
"unused value" warnings occur.

--- 8< --- strncmp2.cocci ---
@@
expression e1, e2;
identifier i2;
@@

  i2 = strlen(e2)
  ...
- strncmp(e1, e2, i2) == 0
+ str_begins(e1, e2)

@@
expression e1, e2;
identifier i2;
@@

  i2 = strlen(e2)
  ...
- strncmp(e1, e2, i2) != 0
+ !str_begins(e1, e2)

@@
expression e1, e2;
identifier i1;
@@

  i1 = strlen(e1)
  ...
- strncmp(e1, e2, i1) == 0
+ str_begins(e2, e1)

@@
expression e1, e2;
identifier i1;
@@

  i1 = strlen(e1)
  ...
- strncmp(e1, e2, i1) != 0
+ !str_begins(e2, e1)

--- 8< ---------------------

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agoglobal - migrate from strncmp to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:20:09 +0000 (15:20 +0200)] 
global - migrate from strncmp to str_begins

Simplify a bunch of verbose strncmp(,,strlen()) calls.

--- 8< --- strncmp.cocci ---
@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e2)) == 0
+ str_begins(e1, e2)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e2)) != 0
+ !str_begins(e1, e2)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e1)) == 0
+ str_begins(e2, e1)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e1)) != 0
+ !str_begins(e2, e1)

--- 8< ---------------------

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agoglobal - migrate strncmp literals to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:03:36 +0000 (15:03 +0200)] 
global - migrate strncmp literals to str_begins

Simplify a bunch of strncmp(,,number) calls.

git ls-files \*.[ch] | xargs perl -p -i -e 's/strncmp\((.*?), ?(\".*?\"), ?(\d+)\) == 0/str_begins($1, $2)/g'
git ls-files \*.[ch] | xargs perl -p -i -e 's/strncmp\((.*?), ?(\".*?\"), ?(\d+)\) != 0/!str_begins($1, $2)/g'

I ran a longer script to verify that all of the string literals and
the length matched. They didn't:

$ git grep strncmp | perl -ne 'print if(m/strncmp\([^,]*,\s*"(.*?)",\s*(\d+)/ and ($s=$1,$t=$2,$s=~s/\\[tn]/#/g,length($s)) != $t)'
src/auth/db-oauth2.c:               if (strncmp(field, "oauth2:", 8) == 0 &&

With the new functions, that kind of typo is impossible.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agolib: strfuncs - string match length and prefix checking helpers
Phil Carmody [Thu, 2 Feb 2017 12:27:58 +0000 (14:27 +0200)] 
lib: strfuncs - string match length and prefix checking helpers

strncmp(input, "literal", 7) is an idiom used everywhere, but leaves
room for human error in calculating the length.

strncmp(input, "literal", strlen("literal")) is an idiom also used
everywhere, but is both verbose and might be inefficient on some
legacy or ultralightweight compilers.

The old techniques are presumed to be optimal code-wise, but are
verbose (and, containing redundancy, they leave room for human error),
so make the macro fall back onto this operation, simply avoiding the
redundancy/verbosity.

The macro expansion does not multiply evaluate any of its parameters,
so should be safe even in the strangest of situations.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agolib: uni_utf8_get_valid_data() - Add ATTR_WARN_UNUSED_RESULT
Timo Sirainen [Wed, 25 Apr 2018 12:23:35 +0000 (15:23 +0300)] 
lib: uni_utf8_get_valid_data() - Add ATTR_WARN_UNUSED_RESULT

Ignoring the return value most likely leads to buggy code, so make sure it's
checked.

7 years agolib-storage: Don't ignore uni_utf8_get_valid_data() return value
Timo Sirainen [Wed, 25 Apr 2018 12:22:37 +0000 (15:22 +0300)] 
lib-storage: Don't ignore uni_utf8_get_valid_data() return value

It's not supposed to happen, so call i_unreached()

7 years agolib-fts: Minor fix to randomness test in test-fts-tokenizer
Timo Sirainen [Wed, 25 Apr 2018 12:20:58 +0000 (15:20 +0300)] 
lib-fts: Minor fix to randomness test in test-fts-tokenizer

If the random input was entirely valid UTF-8, the input was truncated to
empty.

7 years agofts: Fix indexing input that contains NULs
Timo Sirainen [Wed, 25 Apr 2018 12:17:53 +0000 (15:17 +0300)] 
fts: Fix indexing input that contains NULs

Any message_block that contained NULs, but otherwise was valid UTF-8, was
simply dropped.

7 years agolast-login: Remove superfluous semicolon
Michael Slusarz [Mon, 16 Apr 2018 16:38:21 +0000 (10:38 -0600)] 
last-login: Remove superfluous semicolon

7 years agolast-login: Username is already output as part of log prefix
Michael Slusarz [Mon, 16 Apr 2018 16:37:32 +0000 (10:37 -0600)] 
last-login: Username is already output as part of log prefix

7 years agolib-http: test-http-client - Only load existing CAs
Aki Tuomi [Wed, 28 Mar 2018 06:11:55 +0000 (09:11 +0300)] 
lib-http: test-http-client - Only load existing CAs

Otherwise the SSL tests do not properly work.

Fixes Error: HTTP Request failed: Couldn't initialize SSL context: Can't load CA certs from directory /etc/ssl/certs: error:02001002:system library:fopen:No such file or directory: fopen('/etc/pki/tls/cert.pem','r'), error:2006D080:BIO routines:BIO_new_file:no such file, error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

7 years agolib-http: test-http-client - Test against missing SAN name
Aki Tuomi [Tue, 27 Mar 2018 07:31:53 +0000 (10:31 +0300)] 
lib-http: test-http-client - Test against missing SAN name

Add test to make sure http client validates and ignores
missing subjectAltName in cert, when not validating names.

7 years agolib-ssl-iostream: Do not skip cert name check if invalid cert is allowed
Aki Tuomi [Tue, 27 Mar 2018 07:20:54 +0000 (10:20 +0300)] 
lib-ssl-iostream: Do not skip cert name check if invalid cert is allowed

Caller should be responsible for ignoring this error, not us.
All the locations calling here are dealing this correctly.

7 years agolib-ssl-iostream: Fix missing altName handling in openssl_cert_match_name
Aki Tuomi [Tue, 27 Mar 2018 07:29:49 +0000 (10:29 +0300)] 
lib-ssl-iostream: Fix missing altName handling in openssl_cert_match_name

If name is not found in subjectAltNames, report it as error.

Fixes Panic: file iostream-openssl-common.c: line 177 (openssl_cert_match_name): assertion failed: (*reason_r != NULL)

7 years agolib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
Timo Sirainen [Wed, 25 Apr 2018 11:19:27 +0000 (14:19 +0300)] 
lib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag

As mentioned in previous commit, 0x80 isn't valid UTF-8 and we shouldn't
encourage using it. This implementation also can't be easily changed to
use unicode replacement character without larger changes to istream-nonuls.

Reverts 95fba2c295bb84639dc64ca5c9f2ccb9edc00ba7.

7 years agolib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead
Timo Sirainen [Wed, 25 Apr 2018 11:17:34 +0000 (14:17 +0300)] 
lib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead

Using 0x80 produces invalid UTF-8 output, which we should avoid. Some places
in Dovecot code already requires that input is valid UTF-8, so it's also
safer and easier to use the unicode replacement character.

Fixes: Panic: file fts-tokenizer-generic.c: line 210 (fts_tokenizer_generic_simple_next): assertion failed: (char_size > 0)
7 years agolib-mail: Change rfc822_parser_context.nul_replacement_char to string
Timo Sirainen [Wed, 25 Apr 2018 11:11:43 +0000 (14:11 +0300)] 
lib-mail: Change rfc822_parser_context.nul_replacement_char to string

7 years agolib: Call module's preinit function, when loading
Sergey Kitov [Wed, 18 Apr 2018 10:30:50 +0000 (13:30 +0300)] 
lib: Call module's preinit function, when loading

7 years agoplugins/old-stats: Add old-stats preinit() which opens mail stats io.
Sergey Kitov [Fri, 9 Mar 2018 13:17:29 +0000 (15:17 +0200)] 
plugins/old-stats: Add old-stats preinit() which opens mail stats io.

7 years agodoveadm: Add rebuild attachments command
Aki Tuomi [Thu, 12 Apr 2018 11:09:10 +0000 (14:09 +0300)] 
doveadm: Add rebuild attachments command

Goes thru given mails and resets the attachment indicator.

7 years agolib-storage: Parse mail parts in mail_set_attachment_keywords if not present
Aki Tuomi [Thu, 12 Apr 2018 11:07:54 +0000 (14:07 +0300)] 
lib-storage: Parse mail parts in mail_set_attachment_keywords if not present

7 years agolib-storage: Add error reporting to mail_set_attachment_keywords
Aki Tuomi [Thu, 19 Apr 2018 07:19:15 +0000 (10:19 +0300)] 
lib-storage: Add error reporting to mail_set_attachment_keywords

7 years agodoveadm: mailbox cache decisions - Fatally fail if fields are missing
Aki Tuomi [Wed, 25 Apr 2018 08:04:08 +0000 (11:04 +0300)] 
doveadm: mailbox cache decisions - Fatally fail if fields are missing

7 years agodoveadm stats dump: Add stddev field
Timo Sirainen [Tue, 24 Apr 2018 14:22:00 +0000 (17:22 +0300)] 
doveadm stats dump: Add stddev field

Include it in default output as well.

7 years agodoveadm stats dump: Add -f <fields> parameter
Timo Sirainen [Tue, 24 Apr 2018 13:29:49 +0000 (16:29 +0300)] 
doveadm stats dump: Add -f <fields> parameter

This allows specifying which fields are wanted to be dumped.

7 years agostats: Support dumping any given percentile
Timo Sirainen [Tue, 24 Apr 2018 14:32:21 +0000 (17:32 +0300)] 
stats: Support dumping any given percentile

7 years agostats: Support dumping variance
Timo Sirainen [Tue, 24 Apr 2018 06:52:32 +0000 (09:52 +0300)] 
stats: Support dumping variance

7 years agolib-mail: message_part_*_parse_from_header() - Replace NULs with 0x80
Timo Sirainen [Tue, 24 Apr 2018 15:01:03 +0000 (18:01 +0300)] 
lib-mail: message_part_*_parse_from_header() - Replace NULs with 0x80

This avoids truncation of Content-*, Subject, Message-ID, In-Reply-To and
Date headers in IMAP ENVELOPE, BODY and BODYSTRUCTURE replies. Of course,
NULs in headers are violating RFCs already, so the previous behavior wasn't
really wrong either.

7 years agodsync: If lock file can't be created because home is missing, mkdir the home
Timo Sirainen [Tue, 24 Apr 2018 15:50:38 +0000 (18:50 +0300)] 
dsync: If lock file can't be created because home is missing, mkdir the home

7 years agolib-storage: Add mail_user_home_mkdir()
Timo Sirainen [Tue, 24 Apr 2018 15:47:28 +0000 (18:47 +0300)] 
lib-storage: Add mail_user_home_mkdir()

7 years agodoveadm: Add mailbox cache manipulation commands
Aki Tuomi [Fri, 13 Apr 2018 10:28:47 +0000 (13:28 +0300)] 
doveadm: Add mailbox cache manipulation commands

This allows changing cache decisions and dropping cache pointer
for wanted mails.

7 years agodoveadm-mail: Handle field conversion to short opt better
Aki Tuomi [Sat, 14 Apr 2018 11:31:44 +0000 (14:31 +0300)] 
doveadm-mail: Handle field conversion to short opt better

Convert non-string types as well

7 years agodoveadm save: Fix using <file without panic
Timo Sirainen [Mon, 23 Apr 2018 12:05:06 +0000 (15:05 +0300)] 
doveadm save: Fix using <file without panic

When getting input with <file with Linux/epoll, it crashed with:

Panic: epoll_ctl(add, 0) failed: Operation not permitted (fd doesn't support epoll - instead of '<file', try 'cat file|')

7 years agolib: Add test for rng
Aki Tuomi [Sun, 25 Mar 2018 16:54:48 +0000 (19:54 +0300)] 
lib: Add test for rng

7 years agolib: stats-dist - Add accessor for samples
Aki Tuomi [Sun, 25 Mar 2018 18:04:49 +0000 (21:04 +0300)] 
lib: stats-dist - Add accessor for samples

7 years agolib: stats-dist - Add variance
Aki Tuomi [Sun, 25 Mar 2018 16:59:15 +0000 (19:59 +0300)] 
lib: stats-dist - Add variance

7 years agolib: rand - Fix potential modulo bias
Aki Tuomi [Sun, 25 Mar 2018 16:49:13 +0000 (19:49 +0300)] 
lib: rand - Fix potential modulo bias

7 years agoimap-hibernate: Log error when connect(imap-master) fails
Timo Sirainen [Sun, 22 Apr 2018 10:11:16 +0000 (13:11 +0300)] 
imap-hibernate: Log error when connect(imap-master) fails

It was previously logged only with info-level.

7 years agolib-storage: Don't add trailing NUL to strings in dovecot.index.cache
Timo Sirainen [Mon, 23 Apr 2018 10:39:13 +0000 (13:39 +0300)] 
lib-storage: Don't add trailing NUL to strings in dovecot.index.cache

They are unnecessary and just unnecessarily consume disk space. The
existing reading code works even if they don't exist, so this change won't
break backwards compatibility.

7 years agolib: Mark str_append_n() deprecated
Timo Sirainen [Sat, 21 Apr 2018 13:21:33 +0000 (16:21 +0300)] 
lib: Mark str_append_n() deprecated

It was almost always used wrongly. Most of the time str_append_data()
should have been used instead. str_append_max() has the old functionality.

7 years agolib: Add ATTR_DEPRECATED macro
Timo Sirainen [Sat, 21 Apr 2018 13:19:43 +0000 (16:19 +0300)] 
lib: Add ATTR_DEPRECATED macro

7 years agoglobal: Replace str_append_n() with str_append_max()
Timo Sirainen [Sat, 21 Apr 2018 13:17:03 +0000 (16:17 +0300)] 
global: Replace str_append_n() with str_append_max()

7 years agolib-fts: fts-tokenizer-address - Cleanup NUL handling in parent_data
Timo Sirainen [Sat, 21 Apr 2018 13:07:21 +0000 (16:07 +0300)] 
lib-fts: fts-tokenizer-address - Cleanup NUL handling in parent_data

The end result is anyway that the token will be truncated at the first NUL.
This change just makes the code a bit more understandable on where the
truncation will happen.

7 years agolib: str_append_[tab]unescaped(): Don't truncate input at NULs
Timo Sirainen [Sat, 21 Apr 2018 12:44:11 +0000 (15:44 +0300)] 
lib: str_append_[tab]unescaped(): Don't truncate input at NULs

For str_append_tabunescaped() the input is supposed to have NULs already
escaped though, so it was truncating only with invalid input.

7 years agoglobal: Replace str_append_n() with str_append_data() wherever possible
Timo Sirainen [Sat, 21 Apr 2018 12:24:28 +0000 (15:24 +0300)] 
global: Replace str_append_n() with str_append_data() wherever possible

It shouldn't be possible for input to have NULs in any of these places.
This makes the extra NUL-check in str_append_n() unnecessary.

7 years agolib: Add str_append_max()
Timo Sirainen [Sat, 21 Apr 2018 13:11:48 +0000 (16:11 +0300)] 
lib: Add str_append_max()

It's otherwise the same as str_append_n(), except it takes const char* as
input instead of const void*. This, as well as its name, should make it
less likely to be used wrong when the input may legitimately have NULs.

The unit test is changed from str_append_n() to str_append_max(), because
str_append_n() will be deprecated.

7 years agolib: Improve str_append_n() comment
Timo Sirainen [Sat, 21 Apr 2018 13:10:03 +0000 (16:10 +0300)] 
lib: Improve str_append_n() comment

7 years agolib-mail: Add MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
Sergey Kitov [Wed, 11 Apr 2018 11:41:45 +0000 (14:41 +0300)] 
lib-mail: Add MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag

The flag signals that input stream for message_parse_header() should replace
0x0 symbols with 0x80.

7 years agolib-mail: rfc2231_parse() - Replace NULs with 0x80
Timo Sirainen [Sat, 21 Apr 2018 13:47:16 +0000 (16:47 +0300)] 
lib-mail: rfc2231_parse() - Replace NULs with 0x80

Instead of truncating the strings at NULs.

7 years agolib-mail: message_address_parse*() - Replace NULs with 0x80
Timo Sirainen [Sat, 21 Apr 2018 13:34:05 +0000 (16:34 +0300)] 
lib-mail: message_address_parse*() - Replace NULs with 0x80

Instead of truncating the strings at NULs.

7 years agolib-mail: rfc822-parser: Add nul_replacement_char
Timo Sirainen [Sat, 21 Apr 2018 13:27:21 +0000 (16:27 +0300)] 
lib-mail: rfc822-parser: Add nul_replacement_char

7 years agolib-mail: rfc822-parser: Strip away folding whitespace from comments
Timo Sirainen [Sat, 21 Apr 2018 10:46:21 +0000 (13:46 +0300)] 
lib-mail: rfc822-parser: Strip away folding whitespace from comments

7 years agolib-mail: rfc822-parser: Improve domain-literal parsing
Timo Sirainen [Sat, 21 Apr 2018 10:28:34 +0000 (13:28 +0300)] 
lib-mail: rfc822-parser: Improve domain-literal parsing

Strip away folding whitespace. Treat any extra '[' as an error.

7 years agolib-mail: rfc822-parser: Don't allow preserving escaped [CR]LF
Timo Sirainen [Sat, 21 Apr 2018 10:05:49 +0000 (13:05 +0300)] 
lib-mail: rfc822-parser: Don't allow preserving escaped [CR]LF

It's not valid to have "\<CR>" or "\<LF>", so the old behavior isn't really
wrong either. However, rfc822_parse_quoted_string() callers are more likely
to expect that the output won't contain any [CR]LF so this new behavior is
a bit better.

7 years agolib-mail: Change rfc822_parse_content_param() API to allow NULs in value
Timo Sirainen [Sat, 21 Apr 2018 09:47:22 +0000 (12:47 +0300)] 
lib-mail: Change rfc822_parse_content_param() API to allow NULs in value

This was the only function in rfc822-parser.h that wasn't NUL-safe.
This won't fix anything, but it makes the rfc822-parser.h API fully
consistent with the NUL handling.

Normally rfc2231_parse() should be called instead of calling
rfc822_parse_content_param() directly, so this shouldn't break any plugins.

7 years agofts-squat: Fix truncating headers at NULs while indexing
Timo Sirainen [Sat, 21 Apr 2018 13:05:16 +0000 (16:05 +0300)] 
fts-squat: Fix truncating headers at NULs while indexing

7 years agologin-common: Consistently truncate client SASL input at first NUL
Timo Sirainen [Sat, 21 Apr 2018 13:03:42 +0000 (16:03 +0300)] 
login-common: Consistently truncate client SASL input at first NUL

The input is supposed to be base64-encoded, so there's no need to support
actual NUL characters. The previous code truncated at NULs, but could have
kept appending more data to the value. This could have produced somewhat
random results.

7 years agolib-master, util: Consistently truncate tabescaped input at the first NUL
Timo Sirainen [Sat, 21 Apr 2018 12:58:15 +0000 (15:58 +0300)] 
lib-master, util: Consistently truncate tabescaped input at the first NUL

The NULs are supposed to come tab-escaped, so there's no need to support
actual NUL characters. The previous code truncated at NULs, but could
have kept appending more data to the value. This could have produced
somewhat random results.

7 years agoconfig: Consistently truncate value at the first NUL in value input file
Timo Sirainen [Sat, 21 Apr 2018 12:53:42 +0000 (15:53 +0300)] 
config: Consistently truncate value at the first NUL in value input file

When value contained "<file", the file was added as a value. The setting
values don't currently support NULs, so the value gets truncated at the
first NUL. However, the previous code could have appended more data to
the value. This could have produced somewhat confusing results.

7 years agodict-fs/memcached-ascii/redis: Consistently truncate value at NULs
Timo Sirainen [Sat, 21 Apr 2018 12:50:08 +0000 (15:50 +0300)] 
dict-fs/memcached-ascii/redis: Consistently truncate value at NULs

The dict API currently doesn't support NULs in values, so they have to be
truncated. However, previously they were truncated at NULs, but more data
may have still been appended to the value. This could have produced
somewhat random results.

7 years agoauth: checkpassword - Fail if input from script contains NULs
Timo Sirainen [Sat, 21 Apr 2018 12:47:23 +0000 (15:47 +0300)] 
auth: checkpassword - Fail if input from script contains NULs

Previously the input was just silently truncated at NULs.

7 years agodoveadm: Fix table printer to not truncate output at NULs
Timo Sirainen [Sat, 21 Apr 2018 12:42:53 +0000 (15:42 +0300)] 
doveadm: Fix table printer to not truncate output at NULs

7 years agodoveadm dump: Don't truncate dovecot.index.cache values at NULs
Timo Sirainen [Sat, 21 Apr 2018 12:41:44 +0000 (15:41 +0300)] 
doveadm dump: Don't truncate dovecot.index.cache values at NULs

7 years agolib-mail: rfc822-parser: Don't truncate comment/quoted-string/domain-literal at NUL
Timo Sirainen [Sat, 21 Apr 2018 11:56:43 +0000 (14:56 +0300)] 
lib-mail: rfc822-parser: Don't truncate comment/quoted-string/domain-literal at NUL

The other tokens couldn't have contained NULs in the first place.

7 years agolib-mail: message_snippet_generate() - Ignore NULs without shrinking snippet size
Timo Sirainen [Sat, 21 Apr 2018 11:53:25 +0000 (14:53 +0300)] 
lib-mail: message_snippet_generate() - Ignore NULs without shrinking snippet size

Previously the NULs also weren't in the snippet content, but they were
included in the snippet size.

7 years agolib-storage: Fix truncating header values at NUL when adding to cache
Timo Sirainen [Sat, 21 Apr 2018 11:31:08 +0000 (14:31 +0300)] 
lib-storage: Fix truncating header values at NUL when adding to cache

For example FETCH BODY.PEEK[HEADER.FIELDS (Subject)] could have returned
the NUL on the first fetch when the mail wasn't in dovecot.index.cache,
but the second FETCH would have returned it truncated at the NUL.

7 years agolib-mail: message-address: Make the parser allow paths that omit `<' and `>'.
Stephan Bosch [Thu, 12 Apr 2018 14:13:08 +0000 (16:13 +0200)] 
lib-mail: message-address: Make the parser allow paths that omit `<' and `>'.

This is a syntax violation, but we allow it to account for a rather wide
selection of software that does not follow the standards.

7 years agolib-mail: message-address: Make parser properly reject paths with spurious trailing...
Stephan Bosch [Thu, 12 Apr 2018 19:27:32 +0000 (21:27 +0200)] 
lib-mail: message-address: Make parser properly reject paths with spurious trailing characters.

7 years agolib-mail: message-address: Make sure incomplete paths are rejected by parser.
Stephan Bosch [Thu, 12 Apr 2018 20:16:54 +0000 (22:16 +0200)] 
lib-mail: message-address: Make sure incomplete paths are rejected by parser.

7 years agolib-mail: message-address: Require paths with an invalid source route to have at...
Stephan Bosch [Thu, 12 Apr 2018 19:59:40 +0000 (21:59 +0200)] 
lib-mail: message-address: Require paths with an invalid source route to have at least a proper `:'.

Otherwise, the parser would allow a bare domain.

7 years agolib-mail: message-address: Properly deinit RFC822 parser in message_address_parse_path().
Stephan Bosch [Thu, 12 Apr 2018 18:29:36 +0000 (20:29 +0200)] 
lib-mail: message-address: Properly deinit RFC822 parser in message_address_parse_path().

7 years agolib-mail: test-message-address: Add test for parsing empty path.
Stephan Bosch [Thu, 12 Apr 2018 18:54:50 +0000 (20:54 +0200)] 
lib-mail: test-message-address: Add test for parsing empty path.

7 years agolib-mail: test-message-address: Use i_memdup() rather than explicit malloc(), memcpy().
Stephan Bosch [Thu, 12 Apr 2018 21:01:03 +0000 (23:01 +0200)] 
lib-mail: test-message-address: Use i_memdup() rather than explicit malloc(), memcpy().

7 years agolib: Added i_memdup().
Stephan Bosch [Thu, 12 Apr 2018 20:58:16 +0000 (22:58 +0200)] 
lib: Added i_memdup().

7 years agolib-ssl-iostream: Fix boolean misuse in SSL_CTX_set_ecdh_auto usage
Aki Tuomi [Tue, 17 Apr 2018 09:20:26 +0000 (12:20 +0300)] 
lib-ssl-iostream: Fix boolean misuse in SSL_CTX_set_ecdh_auto usage

f8aaa6e63a56085f61f128838ad7a3aa080d9d5b introduced warnings on gcc

7 years agolib-ssl-iostream: Do not handshake further if we are destroying
Aki Tuomi [Tue, 17 Apr 2018 12:58:58 +0000 (15:58 +0300)] 
lib-ssl-iostream: Do not handshake further if we are destroying

7 years agolib: Implement str_sanitize_utf8(). 79/head
Stephan Bosch [Sat, 14 Apr 2018 00:05:51 +0000 (02:05 +0200)] 
lib: Implement str_sanitize_utf8().

Unlike str_sanitize(), this function truncates strings based on a UTF8 code point
limit rather than a maximum size in bytes. Also, the Unicode replacement
character is used to mark invalid/control characters and an ellipsis character
is used to indicate the string truncation. For the normal str_sanitize() this is
done using a question mark and triple dots respectively.

7 years agolib: unichar: Add Horizontal Ellipsis character.
Stephan Bosch [Tue, 17 Apr 2018 19:31:38 +0000 (21:31 +0200)] 
lib: unichar: Add Horizontal Ellipsis character.

7 years agoimapc: Fix expunges+appends in same session with imapc_features=no-msn-updates
Timo Sirainen [Tue, 17 Apr 2018 12:46:41 +0000 (15:46 +0300)] 
imapc: Fix expunges+appends in same session with imapc_features=no-msn-updates

Since the EXPUNGEs were ignored, the sequence numbers weren't updated.
When a new mail arrived, the sequence number sent by the remote IMAP server
pointed to existing mails in imapc's mapping. Fix this by changing the
sequence number if the returned UID is >= next_uid.

Fixes "FETCH UID mismatch" errors.

7 years agolib-ssl-iostream: Make ssl_iostream_unref() private
Timo Sirainen [Mon, 16 Apr 2018 13:29:38 +0000 (16:29 +0300)] 
lib-ssl-iostream: Make ssl_iostream_unref() private

7 years agoglobal: Replace ssl_iostream_unref() with ssl_iostream_destroy()
Timo Sirainen [Mon, 16 Apr 2018 13:28:24 +0000 (16:28 +0300)] 
global: Replace ssl_iostream_unref() with ssl_iostream_destroy()

Destroying performs cleanups correctly.

7 years agolib-master: Add log_core_filter setting to core dump on matching filter
Timo Sirainen [Mon, 16 Apr 2018 11:01:37 +0000 (14:01 +0300)] 
lib-master: Add log_core_filter setting to core dump on matching filter