From dovecot at dovecot.org Fri May 2 06:29:38 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 06:29:38 +0000 Subject: dovecot-2.2: virtual: Fixed assert-crash when doing changes to b... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/501a19fc2747 changeset: 17299:501a19fc2747 user: Timo Sirainen date: Fri May 02 09:29:05 2014 +0300 description: virtual: Fixed assert-crash when doing changes to backend mailbox via the virtual mailbox. Caused by the recent lazy mailbox opening changes. diffstat: src/plugins/virtual/virtual-sync.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) diffs (81 lines): diff -r c1719de47d5e -r 501a19fc2747 src/plugins/virtual/virtual-sync.c --- a/src/plugins/virtual/virtual-sync.c Wed Apr 30 18:46:55 2014 +0300 +++ b/src/plugins/virtual/virtual-sync.c Fri May 02 09:29:05 2014 +0300 @@ -331,8 +331,8 @@ &ext_hdr.change_counter, sizeof(ext_hdr.change_counter)); } -static void virtual_sync_index_rec(struct virtual_sync_context *ctx, - const struct mail_index_sync_rec *sync_rec) +static int virtual_sync_index_rec(struct virtual_sync_context *ctx, + const struct mail_index_sync_rec *sync_rec) { uint32_t virtual_ext_id = ctx->mbox->virtual_ext_id; struct virtual_backend_box *bbox; @@ -355,7 +355,7 @@ sync_rec->uid1, sync_rec->uid2, &seq1, &seq2)) { /* already expunged, nothing to do. */ - return; + return 0; } for (vseq = seq1; vseq <= seq2; vseq++) { @@ -366,6 +366,13 @@ bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id); if (bbox == NULL) continue; + if (!bbox->box->opened) { + if (mailbox_open(bbox->box) < 0) { + virtual_box_copy_error(&ctx->mbox->box, + bbox->box); + return -1; + } + } virtual_backend_box_sync_mail_set(bbox); if (!mail_set_uid(bbox->sync_mail, vrec->real_uid)) { @@ -405,9 +412,10 @@ break; } } + return 0; } -static void virtual_sync_index_changes(struct virtual_sync_context *ctx) +static int virtual_sync_index_changes(struct virtual_sync_context *ctx) { const ARRAY_TYPE(keywords) *keywords; struct mail_index_sync_rec sync_rec; @@ -415,8 +423,11 @@ keywords = mail_index_get_keywords(ctx->index); ctx->kw_all = array_count(keywords) == 0 ? NULL : array_idx(keywords, 0); - while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) - virtual_sync_index_rec(ctx, &sync_rec); + while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) { + if (virtual_sync_index_rec(ctx, &sync_rec) < 0) + return -1; + } + return 0; } static void virtual_sync_index_finish(struct virtual_sync_context *ctx) @@ -1082,6 +1093,7 @@ } } else { /* sync using the existing search result */ + i_assert(bbox_index_opened); i_array_init(&ctx->sync_expunges, 32); ret = virtual_sync_backend_box_sync(ctx, bbox, sync_flags); if (ret == 0) T_BEGIN { @@ -1511,7 +1523,8 @@ if (ret == 0) ctx->ext_header_rewrite = TRUE; /* apply changes from virtual index to backend mailboxes */ - virtual_sync_index_changes(ctx); + if (virtual_sync_index_changes(ctx) < 0) + return virtual_sync_finish(ctx, FALSE); /* update list of UIDs in backend mailboxes */ if (virtual_sync_backend_boxes(ctx) < 0) return virtual_sync_finish(ctx, FALSE); From dovecot at dovecot.org Fri May 2 07:35:52 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 07:35:52 +0000 Subject: dovecot-2.2: lib-storage: Mailbox list indexes didn't use mail_f... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9b53f6bf0427 changeset: 17300:9b53f6bf0427 user: Timo Sirainen date: Fri May 02 10:35:05 2014 +0300 description: lib-storage: Mailbox list indexes didn't use mail_fsync setting. diffstat: src/lib-storage/list/mailbox-list-index.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 501a19fc2747 -r 9b53f6bf0427 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Fri May 02 09:29:05 2014 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Fri May 02 10:35:05 2014 +0300 @@ -72,6 +72,7 @@ perm.file_create_gid, perm.file_create_gid_origin); + mail_index_set_fsync_mode(ilist->index, set->parsed_fsync_mode, 0); mail_index_set_lock_method(ilist->index, set->parsed_lock_method, lock_timeout); if (mail_index_open_or_create(ilist->index, index_flags) < 0) { From dovecot at dovecot.org Fri May 2 07:40:40 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 07:40:40 +0000 Subject: dovecot-2.2: example-config: Removed mail_nfs_* settings, since ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f9e76b2320c4 changeset: 17301:f9e76b2320c4 user: Timo Sirainen date: Fri May 02 10:40:12 2014 +0300 description: example-config: Removed mail_nfs_* settings, since they shouldn't be used anyway. diffstat: doc/example-config/conf.d/10-mail.conf | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diffs (17 lines): diff -r 9b53f6bf0427 -r f9e76b2320c4 doc/example-config/conf.d/10-mail.conf --- a/doc/example-config/conf.d/10-mail.conf Fri May 02 10:35:05 2014 +0300 +++ b/doc/example-config/conf.d/10-mail.conf Fri May 02 10:40:12 2014 +0300 @@ -146,13 +146,6 @@ # never: Never use it (best performance, but crashes can lose data) #mail_fsync = optimized -# Mail storage exists in NFS. Set this to yes to make Dovecot flush NFS caches -# whenever needed. If you're using only a single mail server this isn't needed. -#mail_nfs_storage = no -# Mail index files also exist in NFS. Setting this to yes requires -# mmap_disable=yes and fsync_disable=no. -#mail_nfs_index = no - # Locking method for index files. Alternatives are fcntl, flock and dotlock. # Dotlocking uses some tricks which may create more disk I/O than other locking # methods. NFS users: flock doesn't work, remember to change mmap_disable. From dovecot at dovecot.org Fri May 2 08:13:26 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 08:13:26 +0000 Subject: dovecot-2.2: imap: If FETCH BINARY fails because of invalid MIME... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/197f77f6ef0d changeset: 17302:197f77f6ef0d user: Timo Sirainen date: Fri May 02 11:06:27 2014 +0300 description: imap: If FETCH BINARY fails because of invalid MIME part data, return [UNKNOWN-CTE] error. diffstat: src/imap/cmd-fetch.c | 6 ++++-- src/imap/imap-fetch-body.c | 21 ++++----------------- 2 files changed, 8 insertions(+), 19 deletions(-) diffs (54 lines): diff -r f9e76b2320c4 -r 197f77f6ef0d src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Fri May 02 10:40:12 2014 +0300 +++ b/src/imap/cmd-fetch.c Fri May 02 11:06:27 2014 +0300 @@ -198,8 +198,10 @@ } errstr = mailbox_get_last_error(cmd->client->mailbox, &error); - if (error == MAIL_ERROR_CONVERSION) { - /* BINARY found unsupported Content-Transfer-Encoding */ + if (error == MAIL_ERROR_CONVERSION || + error == MAIL_ERROR_INVALIDDATA) { + /* a) BINARY found unsupported Content-Transfer-Encoding + b) Content was invalid */ tagged_reply = t_strdup_printf( "NO ["IMAP_RESP_CODE_UNKNOWN_CTE"] %s", errstr); } else { diff -r f9e76b2320c4 -r 197f77f6ef0d src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Fri May 02 10:40:12 2014 +0300 +++ b/src/imap/imap-fetch-body.c Fri May 02 11:06:27 2014 +0300 @@ -163,16 +163,8 @@ return 1; } - if (imap_msgpart_open(mail, body->msgpart, &result) < 0) { - if (!body->binary || - mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA) - return -1; - /* tried to do BINARY fetch for a MIME part with broken - content */ - str = get_prefix(&ctx->state, body, (uoff_t)-1, FALSE); - o_stream_nsend(ctx->client->output, str_data(str), str_len(str)); - return 1; - } + if (imap_msgpart_open(mail, body->msgpart, &result) < 0) + return -1; ctx->state.cur_input = result.input; ctx->state.cur_size = result.size; ctx->state.cur_size_field = result.size_field; @@ -197,13 +189,8 @@ return 1; } - if (imap_msgpart_size(mail, body->msgpart, &size) < 0) { - if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA) - return -1; - /* tried to do BINARY.SIZE fetch for a MIME part with broken - content */ - size = 0; - } + if (imap_msgpart_size(mail, body->msgpart, &size) < 0) + return -1; str = t_str_new(128); if (ctx->state.cur_first) From dovecot at dovecot.org Fri May 2 08:13:26 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 08:13:26 +0000 Subject: dovecot-2.2: imap: Make sure we don't return empty "* n FETCH ()... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/99f59d6fce05 changeset: 17303:99f59d6fce05 user: Timo Sirainen date: Fri May 02 11:12:58 2014 +0300 description: imap: Make sure we don't return empty "* n FETCH ()" reply, which violates RFC 3501 ABNF. It happened only during error conditions, and it would be a bit too much trouble to try to remove the reply entirely, so just append the message UID there. diffstat: src/imap/imap-fetch.c | 14 +++++++++++++- src/imap/imap-fetch.h | 1 + 2 files changed, 14 insertions(+), 1 deletions(-) diffs (49 lines): diff -r 197f77f6ef0d -r 99f59d6fce05 src/imap/imap-fetch.c --- a/src/imap/imap-fetch.c Fri May 02 11:06:27 2014 +0300 +++ b/src/imap/imap-fetch.c Fri May 02 11:12:58 2014 +0300 @@ -403,6 +403,7 @@ len--; ctx->state.cur_first = FALSE; } + ctx->state.cur_flushed = TRUE; if (o_stream_send(ctx->client->output, data, len) < 0) return -1; @@ -483,6 +484,7 @@ str_printfa(state->cur_str, "* %u FETCH (", state->cur_mail->seq); state->cur_first = TRUE; + state->cur_flushed = FALSE; state->line_finished = FALSE; } @@ -591,7 +593,17 @@ if (ctx->state.fetching) { ctx->state.fetching = FALSE; - if (!state->line_finished) { + if (!state->line_finished && + (!state->cur_first || state->cur_flushed)) { + if (state->cur_first) { + /* we've flushed an empty "FETCH (" reply so + far. we can't take it back, but RFC 3501 + doesn't allow returning empty "FETCH ()" + either, so just add the current message's + UID there. */ + str_printfa(ctx->state.cur_str, "UID %u ", + state->cur_mail->uid); + } if (imap_fetch_flush_buffer(ctx) < 0) state->failed = TRUE; if (o_stream_send(ctx->client->output, ")\r\n", 3) < 0) diff -r 197f77f6ef0d -r 99f59d6fce05 src/imap/imap-fetch.h --- a/src/imap/imap-fetch.h Fri May 02 11:06:27 2014 +0300 +++ b/src/imap/imap-fetch.h Fri May 02 11:12:58 2014 +0300 @@ -63,6 +63,7 @@ unsigned int fetching:1; unsigned int seen_flags_changed:1; unsigned int cur_first:1; + unsigned int cur_flushed:1; unsigned int line_partial:1; unsigned int line_finished:1; unsigned int skipped_expunged_msgs:1; From dovecot at dovecot.org Fri May 2 08:40:34 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 08:40:34 +0000 Subject: dovecot-2.2: auth: Fixed userdb extra fields handling in passdb ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e84555e6eb59 changeset: 17304:e84555e6eb59 user: Timo Sirainen date: Fri May 02 11:40:05 2014 +0300 description: auth: Fixed userdb extra fields handling in passdb failure. userdb prefetch -flag wasn't correctly set, causing the prefetch userdb in some situations incorrectly either to be called or not be called. This also fixes a crash when using userdb static and multiple passdbs. The userdb_reply was set to NULL, which caused a crash later. diffstat: src/auth/auth-request.c | 13 +++++-------- src/auth/auth-request.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diffs (42 lines): diff -r 99f59d6fce05 -r e84555e6eb59 src/auth/auth-request.c --- a/src/auth/auth-request.c Fri May 02 11:12:58 2014 +0300 +++ b/src/auth/auth-request.c Fri May 02 11:40:05 2014 +0300 @@ -625,21 +625,18 @@ /* this passdb lookup succeeded, preserve its extra fields */ auth_fields_snapshot(request->extra_fields); - request->snapshot_has_userdb_reply = - request->userdb_reply != NULL; + request->snapshot_have_userdb_prefetch_set = + request->userdb_prefetch_set; if (request->userdb_reply != NULL) auth_fields_snapshot(request->userdb_reply); } else { /* this passdb lookup failed, remove any extra fields it set */ auth_fields_rollback(request->extra_fields); - if (request->userdb_reply == NULL) - ; - else if (request->snapshot_has_userdb_reply) + if (request->userdb_reply != NULL) { auth_fields_rollback(request->userdb_reply); - else { - request->userdb_reply = NULL; - request->userdb_prefetch_set = FALSE; + request->userdb_prefetch_set = + request->snapshot_have_userdb_prefetch_set; } } diff -r 99f59d6fce05 -r e84555e6eb59 src/auth/auth-request.h --- a/src/auth/auth-request.h Fri May 02 11:12:58 2014 +0300 +++ b/src/auth/auth-request.h Fri May 02 11:40:05 2014 +0300 @@ -124,7 +124,7 @@ unsigned int prefer_plain_credentials:1; unsigned int in_delayed_failure_queue:1; unsigned int removed_from_handler:1; - unsigned int snapshot_has_userdb_reply:1; + unsigned int snapshot_have_userdb_prefetch_set:1; /* each passdb lookup can update the current success-status using the result_* rules. the authentication succeeds only if this is TRUE at the end. mechanisms that don't require passdb, but do a passdb From dovecot at dovecot.org Fri May 2 08:59:32 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 08:59:32 +0000 Subject: dovecot-2.2: lib-storage: mailbox_settings_find() now takes name... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/930b6b1346bd changeset: 17305:930b6b1346bd user: Timo Sirainen date: Fri May 02 11:58:52 2014 +0300 description: lib-storage: mailbox_settings_find() now takes namespace parameter instead of user. This fixes an infinite (until stack gets full) loop with shared mailboxes: mail_namespace_find() -> mailbox_list_get_storage() -> mailbox_settings_find() -> mail_namespace_find() -> ... diffstat: src/lib-storage/list/mailbox-list-iter.c | 2 +- src/lib-storage/mail-storage.c | 6 ++---- src/lib-storage/mail-storage.h | 2 +- src/lib-storage/mailbox-list.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diffs (62 lines): diff -r e84555e6eb59 -r 930b6b1346bd src/lib-storage/list/mailbox-list-iter.c --- a/src/lib-storage/list/mailbox-list-iter.c Fri May 02 11:40:05 2014 +0300 +++ b/src/lib-storage/list/mailbox-list-iter.c Fri May 02 11:58:52 2014 +0300 @@ -958,7 +958,7 @@ ctx->list->ns->flags |= NAMESPACE_FLAG_USABLE; if ((ctx->flags & MAILBOX_LIST_ITER_RETURN_SPECIALUSE) != 0) { - set = mailbox_settings_find(ctx->list->ns->user, info->vname); + set = mailbox_settings_find(ctx->list->ns, info->vname); if (set != NULL && *set->special_use != '\0') { ctx->specialuse_info = *info; ctx->specialuse_info.special_use = diff -r e84555e6eb59 -r 930b6b1346bd src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri May 02 11:40:05 2014 +0300 +++ b/src/lib-storage/mail-storage.c Fri May 02 11:58:52 2014 +0300 @@ -620,12 +620,10 @@ } const struct mailbox_settings * -mailbox_settings_find(struct mail_user *user, const char *vname) +mailbox_settings_find(struct mail_namespace *ns, const char *vname) { struct mailbox_settings *const *box_set; - struct mail_namespace *ns; - ns = mail_namespace_find(user->namespaces, vname); if (!array_is_created(&ns->set->mailboxes)) return NULL; @@ -687,7 +685,7 @@ } box = storage->v.mailbox_alloc(storage, new_list, vname, flags); - box->set = mailbox_settings_find(storage->user, vname); + box->set = mailbox_settings_find(new_list->ns, vname); box->open_error = open_error; if (open_error != 0) mail_storage_set_error(storage, open_error, errstr); diff -r e84555e6eb59 -r 930b6b1346bd src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Fri May 02 11:40:05 2014 +0300 +++ b/src/lib-storage/mail-storage.h Fri May 02 11:58:52 2014 +0300 @@ -540,7 +540,7 @@ mailbox_get_settings(struct mailbox *box) ATTR_PURE; /* Returns the mailbox's settings, or NULL if there are none. */ const struct mailbox_settings * -mailbox_settings_find(struct mail_user *user, const char *vname); +mailbox_settings_find(struct mail_namespace *ns, const char *vname); /* Returns the (virtual) name of the given mailbox. */ const char *mailbox_get_vname(const struct mailbox *box) ATTR_PURE; diff -r e84555e6eb59 -r 930b6b1346bd src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri May 02 11:40:05 2014 +0300 +++ b/src/lib-storage/mailbox-list.c Fri May 02 11:58:52 2014 +0300 @@ -818,7 +818,7 @@ if ((*list)->v.get_storage != NULL) return (*list)->v.get_storage(list, vname, storage_r); - set = mailbox_settings_find((*list)->ns->user, vname); + set = mailbox_settings_find((*list)->ns, vname); if (set != NULL && set->driver != NULL && set->driver[0] != '\0') { return mailbox_list_get_storage_driver(*list, set->driver, storage_r); From dovecot at dovecot.org Fri May 2 09:12:46 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 09:12:46 +0000 Subject: dovecot-2.2: lib-index: Fixed crash when header fields count was... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1f2c83d6dd2e changeset: 17306:1f2c83d6dd2e user: Timo Sirainen date: Fri May 02 12:11:54 2014 +0300 description: lib-index: Fixed crash when header fields count was too high in cache file. diffstat: src/lib-index/mail-cache-fields.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 930b6b1346bd -r 1f2c83d6dd2e src/lib-index/mail-cache-fields.c --- a/src/lib-index/mail-cache-fields.c Fri May 02 11:58:52 2014 +0300 +++ b/src/lib-index/mail-cache-fields.c Fri May 02 12:11:54 2014 +0300 @@ -328,7 +328,8 @@ /* check the fixed size of the header. name[] has to be checked separately */ - if (field_hdr->size < MAIL_CACHE_FIELD_NAMES(field_hdr->fields_count)) { + if (field_hdr->fields_count > INT_MAX / MAIL_CACHE_FIELD_NAMES(1) || + field_hdr->size < MAIL_CACHE_FIELD_NAMES(field_hdr->fields_count)) { mail_cache_set_corrupted(cache, "invalid field header size"); return -1; } From dovecot at dovecot.org Fri May 2 10:21:47 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 10:21:47 +0000 Subject: dovecot-2.2: kqueue: Changed all i_fatal() calls to i_panic()s t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/304b95de6a5f changeset: 17307:304b95de6a5f user: Timo Sirainen date: Fri May 02 13:21:18 2014 +0300 description: kqueue: Changed all i_fatal() calls to i_panic()s to make debugging them possible. diffstat: src/lib/ioloop-kqueue.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (27 lines): diff -r 1f2c83d6dd2e -r 304b95de6a5f src/lib/ioloop-kqueue.c --- a/src/lib/ioloop-kqueue.c Fri May 02 12:11:54 2014 +0300 +++ b/src/lib/ioloop-kqueue.c Fri May 02 13:21:18 2014 +0300 @@ -64,12 +64,12 @@ if ((io->io.condition & (IO_READ | IO_ERROR)) != 0) { MY_EV_SET(&ev, io->fd, EVFILT_READ, EV_ADD, 0, 0, io); if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0) - i_fatal("kevent(EV_ADD, READ, %d) failed: %m", io->fd); + i_panic("kevent(EV_ADD, READ, %d) failed: %m", io->fd); } if ((io->io.condition & IO_WRITE) != 0) { MY_EV_SET(&ev, io->fd, EVFILT_WRITE, EV_ADD, 0, 0, io); if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0) - i_fatal("kevent(EV_ADD, WRITE, %d) failed: %m", io->fd); + i_panic("kevent(EV_ADD, WRITE, %d) failed: %m", io->fd); } /* allow kevent() to return the maximum number of events @@ -128,7 +128,7 @@ events = array_get_modifiable(&ctx->events, &events_count); ret = kevent (ctx->kq, NULL, 0, events, events_count, &ts); if (ret < 0 && errno != EINTR) - i_fatal("kevent(): %m"); + i_panic("kevent(): %m"); /* reference all IOs */ for (i = 0; i < ret; i++) { From dovecot at dovecot.org Fri May 2 10:36:35 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 10:36:35 +0000 Subject: dovecot-2.2: maildir: Returning mail's received/saved date or re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9f1460682295 changeset: 17308:9f1460682295 user: Timo Sirainen date: Fri May 02 13:36:00 2014 +0300 description: maildir: Returning mail's received/saved date or refcount was sometimes broken with zlib plugin. If the value wasn't already cached and the same transaction also accessed the message body, i_stream_stat() was used, which ended up to i_stream_seekable_stat() due to caching the file, which didn't again fstat() the actual maildir file but just used some internal values. diffstat: src/lib-storage/index/maildir/maildir-mail.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diffs (33 lines): diff -r 304b95de6a5f -r 9f1460682295 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Fri May 02 13:21:18 2014 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Fri May 02 13:36:00 2014 +0300 @@ -106,9 +106,8 @@ { struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->box; struct index_mail *imail = (struct index_mail *)mail; - const struct stat *stp; const char *path; - int ret; + int fd, ret; if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { mail_set_aborted(mail); @@ -123,11 +122,15 @@ (void)mail_get_stream(mail, NULL, NULL, &input); } - if (imail->data.stream != NULL) { + if (imail->data.stream != NULL && + (fd = i_stream_get_fd(imail->data.stream)) != -1) { mail->transaction->stats.fstat_lookup_count++; - if (i_stream_stat(imail->data.stream, FALSE, &stp) < 0) + if (fstat(fd, st_r) < 0) { + mail_storage_set_critical(mail->box->storage, + "fstat(%s) failed: %m", + i_stream_get_name(imail->data.stream)); return -1; - *st_r = *stp; + } } else if (!mail->saving) { mail->transaction->stats.stat_lookup_count++; ret = maildir_file_do(mbox, mail->uid, do_stat, st_r); From dovecot at dovecot.org Fri May 2 10:49:10 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 10:49:10 +0000 Subject: dovecot-2.2: maildir: Maildir S=size fixing now works also with ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a1831c9896d4 changeset: 17309:a1831c9896d4 user: Timo Sirainen date: Fri May 02 13:48:36 2014 +0300 description: maildir: Maildir S=size fixing now works also with zlib etc. plugins that modify the files. diffstat: src/lib-storage/index/maildir/maildir-mail.c | 53 ++++++++++++++++++++------- 1 files changed, 38 insertions(+), 15 deletions(-) diffs (106 lines): diff -r 9f1460682295 -r a1831c9896d4 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Fri May 02 13:36:00 2014 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Fri May 02 13:48:36 2014 +0300 @@ -651,8 +651,14 @@ } } +struct maildir_size_fix_ctx { + uoff_t physical_size; + bool wrong_key; +}; + static int -do_fix_size(struct maildir_mailbox *mbox, const char *path, char *wrong_key_p) +do_fix_size(struct maildir_mailbox *mbox, const char *path, + struct maildir_size_fix_ctx *ctx) { const char *fname, *newpath, *extra, *info, *dir; struct stat st; @@ -666,23 +672,26 @@ info = strchr(fname, MAILDIR_INFO_SEP); if (info == NULL) info = ""; - if (stat(path, &st) < 0) { - if (errno == ENOENT) - return 0; - mail_storage_set_critical(&mbox->storage->storage, - "stat(%s) failed: %m", path); - return -1; + if (ctx->physical_size == (uoff_t)-1) { + if (stat(path, &st) < 0) { + if (errno == ENOENT) + return 0; + mail_storage_set_critical(&mbox->storage->storage, + "stat(%s) failed: %m", path); + return -1; + } + ctx->physical_size = st.st_size; } newpath = t_strdup_printf("%s/%s,S=%"PRIuUOFF_T"%s", dir, t_strdup_until(fname, extra), - (uoff_t)st.st_size, info); + ctx->physical_size, info); if (rename(path, newpath) == 0) { mail_storage_set_critical(mbox->box.storage, "Maildir filename has wrong %c value, " "renamed the file from %s to %s", - *wrong_key_p, path, newpath); + ctx->wrong_key, path, newpath); return 1; } if (errno == ENOENT) @@ -702,10 +711,9 @@ enum maildir_uidlist_rec_flag flags; const char *fname; uoff_t size; - char wrong_key; + struct maildir_size_fix_ctx ctx; - if (mbox->storage->set->maildir_broken_filename_sizes || - pmail->v.istream_opened != NULL) { + if (mbox->storage->set->maildir_broken_filename_sizes) { /* never try to fix sizes in maildir filenames */ return; } @@ -715,20 +723,35 @@ if (strchr(fname, MAILDIR_EXTRA_SEP) == NULL) return; + memset(&ctx, 0, sizeof(ctx)); + ctx.physical_size = (uoff_t)-1; if (field == MAIL_FETCH_VIRTUAL_SIZE && maildir_filename_get_size(fname, MAILDIR_EXTRA_VIRTUAL_SIZE, &size)) { - wrong_key = 'W'; + ctx.wrong_key = 'W'; } else if (field == MAIL_FETCH_PHYSICAL_SIZE && maildir_filename_get_size(fname, MAILDIR_EXTRA_FILE_SIZE, &size)) { - wrong_key = 'S'; + ctx.wrong_key = 'S'; } else { /* the broken size isn't in filename */ return; } - (void)maildir_file_do(mbox, mail->uid, do_fix_size, &wrong_key); + if (pmail->v.istream_opened != NULL) { + /* the mail could be e.g. compressed. get the physical size + the slow way by actually reading the mail. */ + struct istream *input; + const struct stat *stp; + + if (mail_get_stream(mail, NULL, NULL, &input) < 0) + return; + if (i_stream_stat(input, TRUE, &stp) < 0) + return; + ctx.physical_size = stp->st_size; + } + + (void)maildir_file_do(mbox, mail->uid, do_fix_size, &ctx); } static void maildir_mail_set_cache_corrupted(struct mail *_mail, From dovecot at dovecot.org Fri May 2 12:43:58 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 12:43:58 +0000 Subject: dovecot-2.2: imap: Allow longer ID command parameters without di... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3ecb2b831402 changeset: 17310:3ecb2b831402 user: Timo Sirainen date: Fri May 02 15:43:30 2014 +0300 description: imap: Allow longer ID command parameters without disconnecting the client. diffstat: src/imap-login/client.c | 223 +++++++++++++++++++++++++++++++++--------- src/imap-login/client.h | 18 +++ src/lib-imap/imap-id.c | 18 ++- src/lib-imap/imap-id.h | 8 + src/lib-master/master-auth.h | 8 +- 5 files changed, 218 insertions(+), 57 deletions(-) diffs (truncated from 397 to 300 lines): diff -r a1831c9896d4 -r 3ecb2b831402 src/imap-login/client.c --- a/src/imap-login/client.c Fri May 02 13:48:36 2014 +0300 +++ b/src/imap-login/client.c Fri May 02 15:43:30 2014 +0300 @@ -48,6 +48,27 @@ return FALSE; } +static bool client_handle_parser_error(struct imap_client *client, + struct imap_parser *parser) +{ + const char *msg; + bool fatal; + + msg = imap_parser_get_error(parser, &fatal); + if (fatal) { + client_send_reply(&client->common, + IMAP_CMD_REPLY_BYE, msg); + client_destroy(&client->common, + t_strconcat("Disconnected: ", msg, NULL)); + return FALSE; + } + + client_send_reply(&client->common, IMAP_CMD_REPLY_BAD, msg); + client->cmd_finished = TRUE; + client->skip_line = TRUE; + return TRUE; +} + static bool is_login_cmd_disabled(struct client *client) { if (client->secured) { @@ -121,46 +142,91 @@ } static void -client_update_info(struct imap_client *client, const struct imap_arg *args) +client_update_info(struct imap_client *client, + const char *key, const char *value) { - const char *key, *value; - - if (!imap_arg_get_list(args, &args)) - return; - - while (imap_arg_get_string(&args[0], &key) && - imap_arg_get_nstring(&args[1], &value)) { - if (strcasecmp(key, "x-originating-ip") == 0) - (void)net_addr2ip(value, &client->common.ip); - else if (strcasecmp(key, "x-originating-port") == 0) - client->common.remote_port = atoi(value); - else if (strcasecmp(key, "x-connected-ip") == 0) - (void)net_addr2ip(value, &client->common.local_ip); - else if (strcasecmp(key, "x-connected-port") == 0) - client->common.local_port = atoi(value); - else if (strcasecmp(key, "x-proxy-ttl") == 0) - client->common.proxy_ttl = atoi(value); - else if (strcasecmp(key, "x-session-id") == 0) { - client->common.session_id = - p_strdup(client->common.pool, value); - } - args += 2; + if (strcasecmp(key, "x-originating-ip") == 0) + (void)net_addr2ip(value, &client->common.ip); + else if (strcasecmp(key, "x-originating-port") == 0) + client->common.remote_port = atoi(value); + else if (strcasecmp(key, "x-connected-ip") == 0) + (void)net_addr2ip(value, &client->common.local_ip); + else if (strcasecmp(key, "x-connected-port") == 0) + client->common.local_port = atoi(value); + else if (strcasecmp(key, "x-proxy-ttl") == 0) + client->common.proxy_ttl = atoi(value); + else if (strcasecmp(key, "x-session-id") == 0) { + client->common.session_id = + p_strdup(client->common.pool, value); } } -static int cmd_id(struct imap_client *client, const struct imap_arg *args) +static void cmd_id_handle_keyvalue(struct imap_client *client, + const char *key, const char *value) { - const char *value; + if (client->common.trusted && !client->id_logged) + client_update_info(client, key, value); + if (client->cmd_id->log_reply != NULL && + (client->cmd_id->log_keys == NULL || + str_array_icase_find((void *)client->cmd_id->log_keys, key))) + imap_id_log_reply_append(client->cmd_id->log_reply, key, value); +} + +static int cmd_id_handle_args(struct imap_client *client, + const struct imap_arg *arg) +{ + struct imap_client_cmd_id *id = client->cmd_id; + const char *key, *value; + + switch (id->state) { + case IMAP_CLIENT_ID_STATE_LIST: + if (arg->type == IMAP_ARG_NIL) + return 1; + if (arg->type != IMAP_ARG_LIST) + return -1; + if (client->set->imap_id_log[0] == '\0') { + /* no ID logging */ + } else if (client->id_logged) { + /* already logged the ID reply */ + } else { + id->log_reply = str_new(default_pool, 64); + if (strcmp(client->set->imap_id_log, "*") == 0) { + /* log all keys */ + } else { + /* log only specified keys */ + id->log_keys = p_strsplit_spaces(default_pool, + client->set->imap_id_log, " "); + } + } + id->state = IMAP_CLIENT_ID_STATE_KEY; + break; + case IMAP_CLIENT_ID_STATE_KEY: + if (!imap_arg_get_string(arg, &key)) + return -1; + if (i_strocpy(id->key, key, sizeof(id->key)) < 0) + return -1; + id->state = IMAP_CLIENT_ID_STATE_VALUE; + break; + case IMAP_CLIENT_ID_STATE_VALUE: + if (!imap_arg_get_nstring(arg, &value)) + return -1; + cmd_id_handle_keyvalue(client, id->key, value); + id->state = IMAP_CLIENT_ID_STATE_KEY; + break; + } + return 0; +} + +static void cmd_id_finish(struct imap_client *client) +{ + /* finished handling the parameters */ if (!client->id_logged) { client->id_logged = TRUE; - if (client->common.trusted) - client_update_info(client, args); - value = imap_id_args_get_log_reply(args, client->set->imap_id_log); - if (value != NULL) { - client_log(&client->common, - t_strdup_printf("ID sent: %s", value)); + if (client->cmd_id->log_reply != NULL) { + client_log(&client->common, t_strdup_printf( + "ID sent: %s", str_c(client->cmd_id->log_reply))); } } @@ -168,7 +234,72 @@ t_strdup_printf("* ID %s\r\n", imap_id_reply_generate(client->set->imap_id_send))); client_send_reply(&client->common, IMAP_CMD_REPLY_OK, "ID completed."); - return 1; +} + +static void cmd_id_free(struct imap_client *client) +{ + struct imap_client_cmd_id *id = client->cmd_id; + + if (id->log_reply != NULL) + str_free(&id->log_reply); + if (id->log_keys != NULL) + p_strsplit_free(default_pool, id->log_keys); + imap_parser_unref(&id->parser); + + i_free_and_null(client->cmd_id); + client->skip_line = TRUE; +} + +static int cmd_id(struct imap_client *client) +{ + struct imap_client_cmd_id *id; + enum imap_parser_flags parser_flags; + const struct imap_arg *args; + int ret; + + if (client->cmd_id == NULL) { + client->cmd_id = id = i_new(struct imap_client_cmd_id, 1); + id->parser = imap_parser_create(client->common.input, + client->common.output, + MAX_IMAP_LINE); + parser_flags = IMAP_PARSE_FLAG_STOP_AT_LIST; + } else { + id = client->cmd_id; + parser_flags = IMAP_PARSE_FLAG_INSIDE_LIST; + } + + while ((ret = imap_parser_read_args(id->parser, 1, parser_flags, &args)) > 0) { + i_assert(ret == 1); + + if ((ret = cmd_id_handle_args(client, args)) < 0) { + client_send_reply(&client->common, + IMAP_CMD_REPLY_BAD, + "Invalid ID parameters"); + cmd_id_free(client); + return -1; + } + if (ret > 0) { + /* NIL parameter */ + ret = 0; + break; + } + imap_parser_reset(id->parser); + parser_flags = IMAP_PARSE_FLAG_INSIDE_LIST; + } + if (ret == 0) { + /* finished the line */ + cmd_id_finish(client); + cmd_id_free(client); + return 1; + } else if (ret == -1) { + if (!client_handle_parser_error(client, id->parser)) + return 0; + cmd_id_free(client); + return -1; + } else { + i_assert(ret == -2); + return 0; + } } static int cmd_noop(struct imap_client *client) @@ -205,8 +336,6 @@ return cmd_capability(client); if (strcmp(cmd, "STARTTLS") == 0) return cmd_starttls(client); - if (strcmp(cmd, "ID") == 0) - return cmd_id(client, args); if (strcmp(cmd, "NOOP") == 0) return cmd_noop(client); if (strcmp(cmd, "LOGOUT") == 0) @@ -247,24 +376,13 @@ static int client_parse_command(struct imap_client *client, const struct imap_arg **args_r) { - const char *msg; - bool fatal; - switch (imap_parser_read_args(client->parser, 0, 0, args_r)) { case -1: /* error */ - msg = imap_parser_get_error(client->parser, &fatal); - if (fatal) { - client_send_reply(&client->common, - IMAP_CMD_REPLY_BYE, msg); - client_destroy(&client->common, - t_strconcat("Disconnected: ", msg, NULL)); - return FALSE; + if (!client_handle_parser_error(client, client->parser)) { + /* client destroyed */ + return 0; } - - client_send_reply(&client->common, IMAP_CMD_REPLY_BAD, msg); - client->cmd_finished = TRUE; - client->skip_line = TRUE; return -1; case -2: /* not enough data */ @@ -329,6 +447,15 @@ ret = cmd_authenticate(client, &parsed); if (ret == 0 && !parsed) return FALSE; + } else if (strcasecmp(client->cmd_name, "ID") == 0) { + /* ID extensions allows max. 30 parameters, + each max. 1024 bytes long. that brings us over the input + buffer's size, so handle the parameters one at a time */ + ret = cmd_id(client); + if (ret == 0) + return FALSE; + if (ret < 0) + ret = 1; /* don't send the error reply again */ } else { ret = client_parse_command(client, &args); if (ret < 0) diff -r a1831c9896d4 -r 3ecb2b831402 src/imap-login/client.h --- a/src/imap-login/client.h Fri May 02 13:48:36 2014 +0300 +++ b/src/imap-login/client.h Fri May 02 15:43:30 2014 +0300 @@ -2,11 +2,28 @@ #define CLIENT_H #include "net.h" +#include "imap-id.h" #include "client-common.h" /* Master prefix is: <1|0> */ #define IMAP_TAG_MAX_LEN (LOGIN_MAX_MASTER_PREFIX_LEN-2) +enum imap_client_id_state { + IMAP_CLIENT_ID_STATE_LIST = 0, + IMAP_CLIENT_ID_STATE_KEY, + IMAP_CLIENT_ID_STATE_VALUE +}; + From dovecot at dovecot.org Fri May 2 16:32:17 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 May 2014 16:32:17 +0000 Subject: dovecot-2.2: dsync: If we notice that incremental sync won't wor... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/36d07c48049f changeset: 17311:36d07c48049f user: Timo Sirainen date: Fri May 02 19:31:49 2014 +0300 description: dsync: If we notice that incremental sync won't work, don't continue doing it. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 22 +++++++++++++--------- src/doveadm/dsync/dsync-brain-mails.c | 3 +++ 2 files changed, 16 insertions(+), 9 deletions(-) diffs (75 lines): diff -r 3ecb2b831402 -r 36d07c48049f src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Fri May 02 15:43:30 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Fri May 02 19:31:49 2014 +0300 @@ -236,6 +236,14 @@ ret = 0; } } + if (ret == 0) { + i_warning("Failed to do incremental sync for mailbox %s, " + "retry with a full sync", + mailbox_get_vname(brain->box)); + brain->changes_during_sync = TRUE; + brain->require_full_resync = TRUE; + return 0; + } if (!brain->mail_requests) exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_AUTO_EXPORT_MAILS; @@ -249,14 +257,6 @@ last_common_uid, exporter_flags); dsync_brain_sync_mailbox_init_remote(brain, remote_dsync_box); - if (ret == 0) { - i_warning("Failed to do incremental sync for mailbox %s, " - "retry with a full sync", - mailbox_get_vname(brain->box)); - brain->changes_during_sync = TRUE; - brain->require_full_resync = TRUE; - return 0; - } return 1; } @@ -714,7 +714,6 @@ i_assert(local_dsync_box.uid_validity != 0); i_assert(memcmp(dsync_box->mailbox_guid, local_dsync_box.mailbox_guid, sizeof(dsync_box->mailbox_guid)) == 0); - dsync_ibc_send_mailbox(brain->ibc, &local_dsync_box); resync = !dsync_brain_mailbox_update_pre(brain, box, &local_dsync_box, dsync_box); @@ -726,6 +725,7 @@ brain->master_brain ? 'M' : 'S', guid_128_to_string(dsync_box->mailbox_guid)); } + dsync_ibc_send_mailbox(brain->ibc, &local_dsync_box); mailbox_free(&box); return TRUE; } @@ -737,8 +737,12 @@ if (ret == 0 || resync) { brain->changes_during_sync = TRUE; brain->require_full_resync = TRUE; + dsync_brain_sync_mailbox_deinit(brain); + dsync_brain_slave_send_mailbox_lost(brain, dsync_box); + return TRUE; } + dsync_ibc_send_mailbox(brain->ibc, &local_dsync_box); brain->state = DSYNC_STATE_SYNC_MAILS; return TRUE; } diff -r 3ecb2b831402 -r 36d07c48049f src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Fri May 02 15:43:30 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain-mails.c Fri May 02 19:31:49 2014 +0300 @@ -62,6 +62,9 @@ if (ret == 0 || resync) { brain->changes_during_sync = TRUE; brain->require_full_resync = TRUE; + brain->failed = TRUE; + dsync_brain_sync_mailbox_deinit(brain); + return TRUE; } dsync_brain_sync_init_box_states(brain); return TRUE; From dovecot at dovecot.org Mon May 5 11:02:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 11:02:53 +0000 Subject: dovecot-2.2: Added seq_range_array_remove_nth() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0d237a4dacd2 changeset: 17312:0d237a4dacd2 user: Timo Sirainen date: Mon May 05 14:02:16 2014 +0300 description: Added seq_range_array_remove_nth() diffstat: src/lib/seq-range-array.c | 22 ++++++++++++++++++++++ src/lib/seq-range-array.h | 3 +++ src/lib/test-seq-range-array.c | 27 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 0 deletions(-) diffs (89 lines): diff -r 36d07c48049f -r 0d237a4dacd2 src/lib/seq-range-array.c --- a/src/lib/seq-range-array.c Fri May 02 19:31:49 2014 +0300 +++ b/src/lib/seq-range-array.c Mon May 05 14:02:16 2014 +0300 @@ -288,6 +288,28 @@ return ret; } +void seq_range_array_remove_nth(ARRAY_TYPE(seq_range) *array, + uint32_t n, uint32_t count) +{ + struct seq_range_iter iter; + uint32_t seq1, seq2; + + if (count == 0) + return; + + seq_range_array_iter_init(&iter, array); + if (!seq_range_array_iter_nth(&iter, n, &seq1)) { + /* n points beyond array */ + return; + } + if (count-1 >= (uint32_t)-1 - n || + !seq_range_array_iter_nth(&iter, n + (count-1), &seq2)) { + /* count points beyond array */ + seq2 = (uint32_t)-1; + } + seq_range_array_remove_range(array, seq1, seq2); +} + unsigned int seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest, const ARRAY_TYPE(seq_range) *src) { diff -r 36d07c48049f -r 0d237a4dacd2 src/lib/seq-range-array.h --- a/src/lib/seq-range-array.h Fri May 02 19:31:49 2014 +0300 +++ b/src/lib/seq-range-array.h Mon May 05 14:02:16 2014 +0300 @@ -33,6 +33,9 @@ unsigned int ATTR_NOWARN_UNUSED_RESULT seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest, const ARRAY_TYPE(seq_range) *src); +/* Remove count number of sequences from the nth sequence (0 = first). */ +void seq_range_array_remove_nth(ARRAY_TYPE(seq_range) *array, + uint32_t n, uint32_t count); /* Remove sequences from dest that don't exist in src. */ unsigned int ATTR_NOWARN_UNUSED_RESULT seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest, diff -r 36d07c48049f -r 0d237a4dacd2 src/lib/test-seq-range-array.c --- a/src/lib/test-seq-range-array.c Fri May 02 19:31:49 2014 +0300 +++ b/src/lib/test-seq-range-array.c Mon May 05 14:02:16 2014 +0300 @@ -54,6 +54,32 @@ test_end(); } +static void test_seq_range_array_remove_nth(void) +{ + ARRAY_TYPE(seq_range) range; + const struct seq_range *r; + + test_begin("seq_range_array_remove_nth()"); + t_array_init(&range, 8); + seq_range_array_add_range(&range, 1, 5); + seq_range_array_add(&range, 7); + seq_range_array_add_range(&range, 10,20); + test_assert(array_count(&range) == 3); + + seq_range_array_remove_nth(&range, 0, 2); + r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 5); + + seq_range_array_remove_nth(&range, 1, 4); + r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 3); + r = array_idx(&range, 1); test_assert(r->seq1 == 11 && r->seq2 == 20); + + seq_range_array_remove_nth(&range, 5, (uint32_t)-1); + r = array_idx(&range, 1); test_assert(r->seq1 == 11 && r->seq2 == 14); + + test_assert(array_count(&range) == 2); + test_end(); +} + static void test_seq_range_array_random(void) { #define SEQ_RANGE_TEST_BUFSIZE 20 @@ -206,6 +232,7 @@ { test_seq_range_array_add_boundaries(); test_seq_range_array_add_merge(); + test_seq_range_array_remove_nth(); test_seq_range_array_invert(); test_seq_range_array_have_common(); test_seq_range_array_random(); From dovecot at dovecot.org Mon May 5 11:03:27 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 11:03:27 +0000 Subject: dovecot-2.2: imap: Fixed SEARCH PARTIAL to work correctly with U... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/defefebf5f99 changeset: 17313:defefebf5f99 user: Timo Sirainen date: Mon May 05 14:02:58 2014 +0300 description: imap: Fixed SEARCH PARTIAL to work correctly with UIDs and with SORT results. diffstat: src/imap/imap-search.c | 20 ++------------------ 1 files changed, 2 insertions(+), 18 deletions(-) diffs (32 lines): diff -r 0d237a4dacd2 -r defefebf5f99 src/imap/imap-search.c --- a/src/imap/imap-search.c Mon May 05 14:02:16 2014 +0300 +++ b/src/imap/imap-search.c Mon May 05 14:02:58 2014 +0300 @@ -228,26 +228,10 @@ static void imap_search_send_partial(struct imap_search_context *ctx, string_t *str) { - struct seq_range *range; - unsigned int i, count; - str_printfa(str, " PARTIAL (%u:%u ", ctx->partial1, ctx->partial2); - /* we need to be able to handle non-sorted seq ranges (for SORT - replies), so do this ourself instead of using seq_range_array_*() - functions. */ - range = array_get_modifiable(&ctx->result, &count); - for (i = count; i > 0; ) { - i--; - if (range[i].seq1 < ctx->partial1) - range[i].seq1 = ctx->partial1; - if (range[i].seq2 > ctx->partial2) - range[i].seq2 = ctx->partial2; - if (range[i].seq1 > range[i].seq2) { - array_delete(&ctx->result, i, 1); - range = array_get_modifiable(&ctx->result, &count); - } - } + seq_range_array_remove_nth(&ctx->result, ctx->partial2, (uint32_t)-1); + seq_range_array_remove_nth(&ctx->result, 0, ctx->partial1-1); if (array_count(&ctx->result) == 0) { /* no results (in range) */ From dovecot at dovecot.org Mon May 5 11:19:00 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 11:19:00 +0000 Subject: dovecot-2.2: imap: Brought back the original SEARCH PARTIAL code... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/32b6a95c95cc changeset: 17314:32b6a95c95cc user: Timo Sirainen date: Mon May 05 14:18:31 2014 +0300 description: imap: Brought back the original SEARCH PARTIAL code with the minor fix that it actually needed. The new code in v2.2.11 was completely wrong. The code in previous commit was broken with SORT. The original code was correct otherwise, except it couldn't handle partial1 pointing past the valid range. diffstat: src/imap/imap-search.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diffs (51 lines): diff -r defefebf5f99 -r 32b6a95c95cc src/imap/imap-search.c --- a/src/imap/imap-search.c Mon May 05 14:02:58 2014 +0300 +++ b/src/imap/imap-search.c Mon May 05 14:18:31 2014 +0300 @@ -228,10 +228,45 @@ static void imap_search_send_partial(struct imap_search_context *ctx, string_t *str) { + struct seq_range *range; + uint32_t n, diff; + unsigned int i, count, delete_count; + str_printfa(str, " PARTIAL (%u:%u ", ctx->partial1, ctx->partial2); + ctx->partial1--; + ctx->partial2--; - seq_range_array_remove_nth(&ctx->result, ctx->partial2, (uint32_t)-1); - seq_range_array_remove_nth(&ctx->result, 0, ctx->partial1-1); + /* we need to be able to handle non-sorted seq ranges (for SORT + replies), so do this ourself instead of using seq_range_array_*() + functions. */ + range = array_get_modifiable(&ctx->result, &count); + /* delete everything up to partial1 */ + delete_count = 0; + for (i = n = 0; i < count; i++) { + diff = range[i].seq2 - range[i].seq1; + if (n + diff >= ctx->partial1) { + range[i].seq1 += ctx->partial1 - n; + delete_count = i; + break; + } + n += diff + 1; + } + if (i == count) { + /* partial1 points past the result */ + array_clear(&ctx->result); + } else { + /* delete everything after partial2 */ + for (n = ctx->partial1; i < count; i++) { + diff = range[i].seq2 - range[i].seq1; + if (n + diff >= ctx->partial2) { + range[i].seq2 = range[i].seq1 + (ctx->partial2 - n); + array_delete(&ctx->result, i + 1, count-(i+1)); + break; + } + n += diff + 1; + } + array_delete(&ctx->result, 0, delete_count); + } if (array_count(&ctx->result) == 0) { /* no results (in range) */ From dovecot at dovecot.org Mon May 5 11:29:17 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 11:29:17 +0000 Subject: dovecot-2.2: auth: Added %{orig_user}, %{orig_username} and %{or... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1e099feb1dea changeset: 17315:1e099feb1dea user: Timo Sirainen date: Mon May 05 14:28:33 2014 +0300 description: auth: Added %{orig_user}, %{orig_username} and %{orig_domain} variables diffstat: src/auth/auth-request.c | 12 ++++++++++++ src/auth/auth-request.h | 2 +- 2 files changed, 13 insertions(+), 1 deletions(-) diffs (48 lines): diff -r 32b6a95c95cc -r 1e099feb1dea src/auth/auth-request.c --- a/src/auth/auth-request.c Mon May 05 14:18:31 2014 +0300 +++ b/src/auth/auth-request.c Mon May 05 14:28:33 2014 +0300 @@ -2027,6 +2027,9 @@ { '\0', NULL, "domain_last" }, { '\0', NULL, "master_user" }, { '\0', NULL, "session_pid" }, + { '\0', NULL, "orig_user" }, + { '\0', NULL, "orig_username" }, + { '\0', NULL, "orig_domain" }, /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */ { '\0', NULL, NULL } }; @@ -2039,6 +2042,7 @@ const unsigned int auth_count = N_ELEMENTS(auth_request_var_expand_static_tab); struct var_expand_table *tab, *ret_tab; + const char *orig_user; if (escape_func == NULL) escape_func = escape_none; @@ -2116,6 +2120,14 @@ escape_func(auth_request->master_user, auth_request); tab[26].value = auth_request->session_pid == (pid_t)-1 ? NULL : dec2str(auth_request->session_pid); + + orig_user = auth_request->original_username != NULL ? + auth_request->original_username : auth_request->user; + tab[27].value = escape_func(orig_user, auth_request); + tab[28].value = escape_func(t_strcut(orig_user, '@'), auth_request); + tab[29].value = strchr(orig_user, '@'); + if (tab[29].value != NULL) + tab[29].value = escape_func(tab[29].value+1, auth_request); return ret_tab; } diff -r 32b6a95c95cc -r 1e099feb1dea src/auth/auth-request.h --- a/src/auth/auth-request.h Mon May 05 14:18:31 2014 +0300 +++ b/src/auth/auth-request.h Mon May 05 14:28:33 2014 +0300 @@ -149,7 +149,7 @@ #define AUTH_REQUEST_VAR_TAB_USER_IDX 0 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2 -#define AUTH_REQUEST_VAR_TAB_COUNT 27 +#define AUTH_REQUEST_VAR_TAB_COUNT 30 extern const struct var_expand_table auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1]; From dovecot at dovecot.org Mon May 5 11:57:49 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 11:57:49 +0000 Subject: dovecot-2.2: lib-mail: message_header_encode() needs to encode c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/88a8e7d9f2e9 changeset: 17316:88a8e7d9f2e9 user: Timo Sirainen date: Mon May 05 14:57:13 2014 +0300 description: lib-mail: message_header_encode() needs to encode control characters as well. diffstat: src/lib-mail/message-header-encode.c | 9 +++++++-- src/lib-mail/test-message-header-encode.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diffs (45 lines): diff -r 1e099feb1dea -r 88a8e7d9f2e9 src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Mon May 05 14:28:33 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Mon May 05 14:57:13 2014 +0300 @@ -13,9 +13,14 @@ static bool input_idx_need_encoding(const unsigned char *input, unsigned int i) { + /* 8bit chars */ if ((input[i] & 0x80) != 0) return TRUE; + /* control chars */ + if (input[i] < 32) + return TRUE; + /* =? */ if (input[i] == '=' && input[i+1] == '?' && (i == 0 || IS_LWSP(input[i-1]))) return TRUE; @@ -65,12 +70,12 @@ case '?': case '_': line_len_left -= 2; - str_printfa(output, "=%2X", input[i]); + str_printfa(output, "=%02X", input[i]); break; default: if (input[i] < 32 || (input[i] & 0x80) != 0) { line_len_left -= 2; - str_printfa(output, "=%2X", input[i]); + str_printfa(output, "=%02X", input[i]); } else { str_append_c(output, input[i]); } diff -r 1e099feb1dea -r 88a8e7d9f2e9 src/lib-mail/test-message-header-encode.c --- a/src/lib-mail/test-message-header-encode.c Mon May 05 14:28:33 2014 +0300 +++ b/src/lib-mail/test-message-header-encode.c Mon May 05 14:57:13 2014 +0300 @@ -168,6 +168,8 @@ "a ?? ? b", "a =?utf-8?b?w6TDpCDDpA==?= b", "? a ?", "=?utf-8?q?=C3=A4_a_=C3=A4?=", "?? a ?", "=?utf-8?b?w6TDpCBhIMOk?=", + "foo\001bar", "=?utf-8?q?foo=01bar?=", + "\x01\x02\x03\x04\x05\x06\x07\x08", "=?utf-8?b?AQIDBAUGBwg=?=" }; string_t *str = t_str_new(128); unsigned int i; From dovecot at dovecot.org Mon May 5 12:30:01 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 12:30:01 +0000 Subject: dovecot-2.2: lib: quell sparse "warning: Using plain integer as ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ef701c458b25 changeset: 17317:ef701c458b25 user: Phil Carmody date: Mon May 05 15:09:27 2014 +0300 description: lib: quell sparse "warning: Using plain integer as NULL pointer" The first element of the structure is a pointer, make that explicit. diffstat: src/lib/array-decl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 88a8e7d9f2e9 -r ef701c458b25 src/lib/array-decl.h --- a/src/lib/array-decl.h Mon May 05 14:57:13 2014 +0300 +++ b/src/lib/array-decl.h Mon May 05 15:09:27 2014 +0300 @@ -2,7 +2,7 @@ #define ARRAY_DECL_H #define ARRAY(array_type) union { struct array arr; array_type const *const *v; array_type **v_modifiable; } -#define ARRAY_INIT { { 0, 0 } } +#define ARRAY_INIT { { NULL, 0 } } #define ARRAY_DEFINE_TYPE(name, array_type) \ union array ## __ ## name { struct array arr; array_type const *const *v; array_type **v_modifiable; } From dovecot at dovecot.org Mon May 5 12:31:39 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 12:31:39 +0000 Subject: dovecot-2.2: liblib: Added str_append_data(), which is simply a ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/841d31e6c647 changeset: 17318:841d31e6c647 user: Timo Sirainen date: Mon May 05 15:05:20 2014 +0300 description: liblib: Added str_append_data(), which is simply a wrapper to buffer_append() This is intended for appending data that may contain NUL characters that are wanted to be added to the string. diffstat: src/lib/str.c | 5 +++++ src/lib/str.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diffs (26 lines): diff -r ef701c458b25 -r 841d31e6c647 src/lib/str.c --- a/src/lib/str.c Mon May 05 15:09:27 2014 +0300 +++ b/src/lib/str.c Mon May 05 15:05:20 2014 +0300 @@ -107,6 +107,11 @@ buffer_append(str, cstr, len); } +void str_append_data(string_t *str, const void *data, size_t len) +{ + buffer_append(str, data, len); +} + void str_append_c(string_t *str, unsigned char chr) { buffer_append_c(str, chr); diff -r ef701c458b25 -r 841d31e6c647 src/lib/str.h --- a/src/lib/str.h Mon May 05 15:09:27 2014 +0300 +++ b/src/lib/str.h Mon May 05 15:05:20 2014 +0300 @@ -20,6 +20,7 @@ /* Append string/character */ void str_append(string_t *str, const char *cstr); void str_append_n(string_t *str, const void *cstr, size_t max_len); +void str_append_data(string_t *str, const void *data, size_t len); void str_append_c(string_t *str, unsigned char chr); void str_append_str(string_t *dest, const string_t *src); From dovecot at dovecot.org Mon May 5 12:40:29 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 12:40:29 +0000 Subject: dovecot-2.2: lib-mail: Added message_header_encode_data() to sup... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cc622a9a2f3c changeset: 17319:cc622a9a2f3c user: Timo Sirainen date: Mon May 05 15:39:58 2014 +0300 description: lib-mail: Added message_header_encode_data() to support encoding also NUL characters. diffstat: src/lib-mail/Makefile.am | 2 +- src/lib-mail/message-header-encode.c | 32 +++++++++++++++++----------- src/lib-mail/message-header-encode.h | 2 + src/lib-mail/test-message-header-decode.c | 34 +++++++++++++++++++++++++++++++ src/lib-mail/test-message-header-encode.c | 16 ++++++++++++++ 5 files changed, 72 insertions(+), 14 deletions(-) diffs (206 lines): diff -r 841d31e6c647 -r cc622a9a2f3c src/lib-mail/Makefile.am --- a/src/lib-mail/Makefile.am Mon May 05 15:05:20 2014 +0300 +++ b/src/lib-mail/Makefile.am Mon May 05 15:39:58 2014 +0300 @@ -134,7 +134,7 @@ test_message_decoder_DEPENDENCIES = $(test_deps) test_message_header_decode_SOURCES = test-message-header-decode.c -test_message_header_decode_LDADD = message-header-decode.lo quoted-printable.lo $(test_libs) +test_message_header_decode_LDADD = message-header-decode.lo quoted-printable.lo message-header-encode.lo $(test_libs) test_message_header_decode_DEPENDENCIES = $(test_deps) test_message_header_encode_SOURCES = test-message-header-encode.c diff -r 841d31e6c647 -r cc622a9a2f3c src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Mon May 05 15:05:20 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Mon May 05 15:39:58 2014 +0300 @@ -11,7 +11,8 @@ #define IS_LWSP(c) \ ((c) == ' ' || (c) == '\t' || (c) == '\n') -static bool input_idx_need_encoding(const unsigned char *input, unsigned int i) +static bool input_idx_need_encoding(const unsigned char *input, + unsigned int i, unsigned int len) { /* 8bit chars */ if ((input[i] & 0x80) != 0) @@ -21,7 +22,7 @@ return TRUE; /* =? */ - if (input[i] == '=' && input[i+1] == '?' && + if (input[i] == '=' && i+1 < len && input[i+1] == '?' && (i == 0 || IS_LWSP(input[i-1]))) return TRUE; return FALSE; @@ -130,21 +131,26 @@ } } -void message_header_encode(const char *_input, string_t *output) +void message_header_encode(const char *input, string_t *output) { - const unsigned char *input = (const unsigned char *)_input; + message_header_encode_data((const void *)input, strlen(input), output); +} + +void message_header_encode_data(const unsigned char *input, unsigned int len, + string_t *output) +{ unsigned int i, first_idx, last_idx; unsigned int enc_chars, enc_len, base64_len, q_len; bool use_q; /* find the first word that needs encoding */ - for (i = 0; input[i] != '\0'; i++) { - if (input_idx_need_encoding(input, i)) + for (i = 0; i < len; i++) { + if (input_idx_need_encoding(input, i, len)) break; } - if (input[i] == '\0') { + if (i == len) { /* no encoding necessary */ - str_append(output, _input); + str_append_data(output, input, len); return; } first_idx = i; @@ -153,13 +159,13 @@ /* find the last word that needs encoding */ last_idx = ++i; enc_chars = 1; - for (; input[i] != '\0'; i++) { - if (input_idx_need_encoding(input, i)) { + for (; i < len; i++) { + if (input_idx_need_encoding(input, i, len)) { last_idx = i + 1; enc_chars++; } } - while (input[last_idx] != '\0' && !IS_LWSP(input[last_idx])) + while (last_idx < len && !IS_LWSP(input[last_idx])) last_idx++; /* figure out if we should use Q or B encoding. Prefer Q if it's not @@ -170,10 +176,10 @@ use_q = q_len*2/3 <= base64_len; /* and do it */ - str_append_n(output, input, first_idx); + str_append_data(output, input, first_idx); if (use_q) message_header_encode_q(input + first_idx, enc_len, output); else message_header_encode_b(input + first_idx, enc_len, output); - str_append(output, _input + last_idx); + str_append_data(output, input + last_idx, len - last_idx); } diff -r 841d31e6c647 -r cc622a9a2f3c src/lib-mail/message-header-encode.h --- a/src/lib-mail/message-header-encode.h Mon May 05 15:05:20 2014 +0300 +++ b/src/lib-mail/message-header-encode.h Mon May 05 15:39:58 2014 +0300 @@ -3,6 +3,8 @@ /* Encode UTF-8 input into output wherever necessary. */ void message_header_encode(const char *input, string_t *output); +void message_header_encode_data(const unsigned char *input, unsigned int len, + string_t *output); /* Encode the whole UTF-8 input using "Q" or "B" encoding into output. The output is split into multiple lines if necessary. The first line length diff -r 841d31e6c647 -r cc622a9a2f3c src/lib-mail/test-message-header-decode.c --- a/src/lib-mail/test-message-header-decode.c Mon May 05 15:05:20 2014 +0300 +++ b/src/lib-mail/test-message-header-decode.c Mon May 05 15:39:58 2014 +0300 @@ -4,9 +4,12 @@ #include "buffer.h" #include "str.h" #include "charset-utf8.h" +#include "message-header-encode.h" #include "message-header-decode.h" #include "test-common.h" +#include + bool charset_is_utf8(const char *charset ATTR_UNUSED) { return TRUE; } int charset_to_utf8_begin(const char *charset ATTR_UNUSED, @@ -25,6 +28,7 @@ static void test_message_header_decode(void) { static const char *data[] = { + " \t=?utf-8?q?=c3=a4?= =?utf-8?q?=c3=a4?= b \t\r\n ", "?? b \t\r\n ", "a =?utf-8?q?=c3=a4?= b", "a ? b", "a =?utf-8?q?=c3=a4?= b", "a ? b", "a =?utf-8?q?=c3=a4?=\t\t\r\n =?utf-8?q?=c3=a4?= b", "a ?? b", @@ -47,10 +51,40 @@ test_end(); } +static void test_message_header_decode_encode_random(void) +{ + string_t *encoded, *decoded; + unsigned char buf[1024]; + unsigned int i, j, buflen; + + test_begin("message header encode & decode randomly"); + + buf[0] = 'x'; + encoded = t_str_new(256); + decoded = t_str_new(256); + for (i = 0; i < 1000; i++) { + /* fill only with 7bit data so we don't have to worry about + the data being valid UTF-8 */ + for (j = 1; j < sizeof(buf); j++) + buf[j] = rand() % 128; + buflen = rand() % sizeof(buf); + + str_truncate(encoded, 0); + str_truncate(decoded, 0); + message_header_encode_data(buf, buflen, encoded); + message_header_decode_utf8(encoded->data, encoded->used, + decoded, NULL); + test_assert(decoded->used == buflen && + memcmp(decoded->data, buf, buflen) == 0); + } + test_end(); +} + int main(void) { static void (*test_functions[])(void) = { test_message_header_decode, + test_message_header_decode_encode_random, NULL }; return test_run(test_functions); diff -r 841d31e6c647 -r cc622a9a2f3c src/lib-mail/test-message-header-encode.c --- a/src/lib-mail/test-message-header-encode.c Mon May 05 15:05:20 2014 +0300 +++ b/src/lib-mail/test-message-header-encode.c Mon May 05 15:39:58 2014 +0300 @@ -183,12 +183,28 @@ test_end(); } +static void test_message_header_encode_data(void) +{ + string_t *str = t_str_new(128); + static unsigned char nuls[10] = { 0, }; + + test_begin("message header encode data"); + message_header_encode_data(nuls, 1, str); + test_assert(strcmp(str_c(str), "=?utf-8?q?=00?=") == 0); + + str_truncate(str, 0); + message_header_encode_data(nuls, sizeof(nuls), str); + test_assert(strcmp(str_c(str), "=?utf-8?b?AAAAAAAAAAAAAA==?=") == 0); + test_end(); +} + int main(void) { static void (*test_functions[])(void) = { test_message_header_encode_q, test_message_header_encode_b, test_message_header_encode, + test_message_header_encode_data, NULL }; return test_run(test_functions); From dovecot at dovecot.org Mon May 5 13:03:33 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 13:03:33 +0000 Subject: dovecot-2.2: doveadm mail fetch: Use mail_get_headers_utf8() whe... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/63361f087d1f changeset: 17320:63361f087d1f user: Timo Sirainen date: Mon May 05 16:00:52 2014 +0300 description: doveadm mail fetch: Use mail_get_headers_utf8() when fetching hdr.*.utf8 This doesn't really matter but may allow minor optimizations later. diffstat: src/doveadm/doveadm-mail-fetch.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diffs (41 lines): diff -r cc622a9a2f3c -r 63361f087d1f src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Mon May 05 15:39:58 2014 +0300 +++ b/src/doveadm/doveadm-mail-fetch.c Mon May 05 16:00:52 2014 +0300 @@ -140,15 +140,19 @@ { const char *const *value, *filter, *name = ctx->cur_field->name; string_t *str = t_str_new(256); - unsigned int pos; bool add_lf = FALSE; filter = strchr(name, '.'); if (filter != NULL) name = t_strdup_until(name, filter++); - if (mail_get_headers(ctx->mail, name, &value) < 0) - return -1; + if (filter != NULL && strcmp(filter, "utf8") == 0) { + if (mail_get_headers_utf8(ctx->mail, name, &value) < 0) + return -1; + } else { + if (mail_get_headers(ctx->mail, name, &value) < 0) + return -1; + } for (; *value != NULL; value++) { if (add_lf) @@ -157,13 +161,8 @@ add_lf = TRUE; } - if (filter == NULL) { + if (filter == NULL || strcmp(filter, "utf8") == 0) { /* print the header as-is */ - } else if (strcmp(filter, "utf8") == 0) { - pos = str_len(str); - message_header_decode_utf8(str_data(str), str_len(str), - str, FALSE); - str_delete(str, 0, pos); } else if (strcmp(filter, "address") == 0 || strcmp(filter, "address_name") == 0 || strcmp(filter, "address_name.utf8") == 0) { From dovecot at dovecot.org Mon May 5 13:03:33 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 13:03:33 +0000 Subject: dovecot-2.2: lib-storage: mail_get_headers_utf8() now replaces N... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4e5f816b59d5 changeset: 17321:4e5f816b59d5 user: Timo Sirainen date: Mon May 05 16:01:58 2014 +0300 description: lib-storage: mail_get_headers_utf8() now replaces NULs with spaces. Perhaps there should also be another API function which actually allows returning strings with NULs in them. diffstat: src/lib-storage/index/index-mail-headers.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diffs (38 lines): diff -r 63361f087d1f -r 4e5f816b59d5 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Mon May 05 16:00:52 2014 +0300 +++ b/src/lib-storage/index/index-mail-headers.c Mon May 05 16:01:58 2014 +0300 @@ -707,6 +707,17 @@ return 0; } +static void str_replace_nuls(string_t *str) +{ + char *data = str_c_modifiable(str); + unsigned int i, len = str_len(str); + + for (i = 0; i < len; i++) { + if (data[i] == '\0') + data[i] = ' '; + } +} + static int index_mail_headers_decode(struct index_mail *mail, const char *const **_list, unsigned int max_count) @@ -731,9 +742,14 @@ /* decode MIME encoded-words. decoding may also add new LFs. */ message_header_decode_utf8((const unsigned char *)input, - strlen(input), str, FALSE); - if (strcmp(str_c(str), input) != 0) + strlen(input), str, NULL); + if (strcmp(str_c(str), input) != 0) { + if (strlen(str_c(str)) != str_len(str)) { + /* replace NULs with spaces */ + str_replace_nuls(str); + } input = p_strdup(mail->mail.data_pool, str_c(str)); + } decoded_list[i] = input; } *_list = decoded_list; From dovecot at dovecot.org Mon May 5 13:03:38 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 13:03:38 +0000 Subject: dovecot-2.2: message_header_decode_utf8() wasn't used correctly ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d60c5ef63d63 changeset: 17322:d60c5ef63d63 user: Timo Sirainen date: Mon May 05 16:02:48 2014 +0300 description: message_header_decode_utf8() wasn't used correctly with NULL instead of FALSE parameter. diffstat: src/doveadm/doveadm-mail-fetch.c | 2 +- src/lib-storage/index/index-sort.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 4e5f816b59d5 -r d60c5ef63d63 src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Mon May 05 16:01:58 2014 +0300 +++ b/src/doveadm/doveadm-mail-fetch.c Mon May 05 16:02:48 2014 +0300 @@ -189,7 +189,7 @@ else { message_header_decode_utf8( (const void *)addr->name, - strlen(addr->name), str, FALSE); + strlen(addr->name), str, NULL); } } add_lf = TRUE; diff -r 4e5f816b59d5 -r d60c5ef63d63 src/lib-storage/index/index-sort.c --- a/src/lib-storage/index/index-sort.c Mon May 05 16:01:58 2014 +0300 +++ b/src/lib-storage/index/index-sort.c Mon May 05 16:02:48 2014 +0300 @@ -393,7 +393,7 @@ str = t_str_new(len*2); (void)message_header_decode_utf8( - (const unsigned char *)addr->name, len, str, FALSE); + (const unsigned char *)addr->name, len, str, NULL); if (str_len(str) > 0) { *name_r = str_c(str); return 0; From dovecot at dovecot.org Mon May 5 13:25:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 13:25:23 +0000 Subject: dovecot-2.2: auth: If authentication fails, never send back "nol... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3a5304b63f88 changeset: 17323:3a5304b63f88 user: Timo Sirainen date: Mon May 05 16:24:53 2014 +0300 description: auth: If authentication fails, never send back "nologin" field. This only causes confusion. diffstat: src/auth/auth-request-handler.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r d60c5ef63d63 -r 3a5304b63f88 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Mon May 05 16:02:48 2014 +0300 +++ b/src/auth/auth-request-handler.c Mon May 05 16:24:53 2014 +0300 @@ -274,6 +274,8 @@ { string_t *str = t_str_new(128); + auth_fields_remove(request->extra_fields, "nologin"); + str_printfa(str, "FAIL\t%u", request->id); if (request->user != NULL) auth_str_add_keyvalue(str, "user", request->user); From pigeonhole at rename-it.nl Mon May 5 15:10:11 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 05 May 2014 17:10:11 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: vacation extension: Fixed log... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/d1d4454866ad changeset: 1851:d1d4454866ad user: Stephan Bosch date: Mon May 05 17:09:10 2014 +0200 description: lib-sieve: vacation extension: Fixed log message for discarded response. Presence of :addresses argument was represented incorrectly. diffstat: src/lib-sieve/plugins/vacation/cmd-vacation.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 378362cb36a6 -r d1d4454866ad src/lib-sieve/plugins/vacation/cmd-vacation.c --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Thu May 01 00:07:27 2014 +0200 +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Mon May 05 17:09:10 2014 +0200 @@ -1223,7 +1223,7 @@ "no known (envelope) recipient address found in message headers " "(recipient=<%s>, %sand%s additional `:addresses' are specified)", str_sanitize(recipient, 128), original_recipient, - (ctx->addresses == NULL ? " no" : "")); + (ctx->addresses == NULL || *ctx->addresses == NULL ? " no" : "")); return SIEVE_EXEC_OK; } From dovecot at dovecot.org Mon May 5 15:38:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 May 2014 15:38:09 +0000 Subject: dovecot-2.2: mkdir_parents(): Handle mkdir() EEXIST errors that ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/16212e6d4fd4 changeset: 17324:16212e6d4fd4 user: Timo Sirainen date: Mon May 05 18:37:16 2014 +0300 description: mkdir_parents(): Handle mkdir() EEXIST errors that may happen during race conditions. We don't care about EEXIST errors that happen when trying to mkdir() parent directories, only if it happens when mkdir()ing the last directory. diffstat: src/lib/mkdir-parents.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3a5304b63f88 -r 16212e6d4fd4 src/lib/mkdir-parents.c --- a/src/lib/mkdir-parents.c Mon May 05 16:24:53 2014 +0300 +++ b/src/lib/mkdir-parents.c Mon May 05 18:37:16 2014 +0300 @@ -112,7 +112,7 @@ mode, uid, gid, gid_origin); } T_END; - if (ret < 0) + if (ret < 0 && errno != EEXIST) return -1; /* should work now */ From dovecot at dovecot.org Tue May 6 12:34:30 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 May 2014 12:34:30 +0000 Subject: dovecot-2.2: pop3: Fixed assert-crash with some settings when th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4493e070c47e changeset: 17325:4493e070c47e user: Timo Sirainen date: Tue May 06 15:34:00 2014 +0300 description: pop3: Fixed assert-crash with some settings when there are 0 mails. diffstat: src/pop3/pop3-commands.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 16212e6d4fd4 -r 4493e070c47e src/pop3/pop3-commands.c --- a/src/pop3/pop3-commands.c Mon May 05 18:37:16 2014 +0300 +++ b/src/pop3/pop3-commands.c Tue May 06 15:34:00 2014 +0300 @@ -838,7 +838,8 @@ struct mail_search_args *search_args; enum mail_fetch_field wanted_fields; - if (client->message_uidls_save && client->message_uidls == NULL) + if (client->message_uidls_save && client->message_uidls == NULL && + client->messages_count > 0) client_uidls_save(client); ctx = i_new(struct cmd_uidl_context, 1); From dovecot at dovecot.org Wed May 7 10:03:24 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 10:03:24 +0000 Subject: dovecot-2.2: lib-compression: Fixed LZMA compression. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8e6d98d34dbf changeset: 17326:8e6d98d34dbf user: Timo Sirainen date: Wed May 07 12:26:38 2014 +0300 description: lib-compression: Fixed LZMA compression. The code now looks more like the doc/examples/01_compress_easy.c distributed with xz-utils. Most importantly this changes LZMA_OK to be allowed as a result for lzma_code(zs, LZMA_FINISH). diffstat: src/lib-compression/ostream-lzma.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) diffs (68 lines): diff -r 4493e070c47e -r 8e6d98d34dbf src/lib-compression/ostream-lzma.c --- a/src/lib-compression/ostream-lzma.c Tue May 06 15:34:00 2014 +0300 +++ b/src/lib-compression/ostream-lzma.c Wed May 07 12:26:38 2014 +0300 @@ -83,7 +83,8 @@ } } - switch (lzma_code(zs, LZMA_RUN)) { + ret = lzma_code(zs, LZMA_RUN); + switch (ret) { case LZMA_OK: break; case LZMA_MEM_ERROR: @@ -91,7 +92,8 @@ "lzma.write(%s): Out of memory", o_stream_get_name(&zstream->ostream.ostream)); default: - i_unreached(); + i_panic("lzma.write(%s) failed with unexpected code %d", + o_stream_get_name(&zstream->ostream.ostream), ret); } } size -= zs->avail_in; @@ -122,20 +124,10 @@ i_assert(zstream->outbuf_used == 0); do { - len = sizeof(zstream->outbuf) - zs->avail_out; - if (len != 0) { - zs->next_out = zstream->outbuf; - zs->avail_out = sizeof(zstream->outbuf); - - zstream->outbuf_used = len; - if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0) - return ret; - if (done) - break; - } - ret = lzma_code(zs, LZMA_FINISH); switch (ret) { + case LZMA_OK: + break; case LZMA_STREAM_END: done = TRUE; break; @@ -144,9 +136,19 @@ "lzma.write(%s): Out of memory", o_stream_get_name(&zstream->ostream.ostream)); default: - i_unreached(); + i_panic("lzma.write(%s) flush failed with unexpected code %d", + o_stream_get_name(&zstream->ostream.ostream), ret); } - } while (zs->avail_out != sizeof(zstream->outbuf)); + if (zs->avail_out == 0 || done) { + len = sizeof(zstream->outbuf) - zs->avail_out; + zs->next_out = zstream->outbuf; + zs->avail_out = sizeof(zstream->outbuf); + + zstream->outbuf_used = len; + if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0) + return ret; + } + } while (!done); zstream->flushed = TRUE; return 0; From dovecot at dovecot.org Wed May 7 10:03:25 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 10:03:25 +0000 Subject: dovecot-2.2: lib-compression: istream-lz4 shouldn't crash when c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2fe36249c62b changeset: 17327:2fe36249c62b user: Timo Sirainen date: Wed May 07 12:26:58 2014 +0300 description: lib-compression: istream-lz4 shouldn't crash when closing the stream multiple times. diffstat: src/lib-compression/istream-lz4.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 8e6d98d34dbf -r 2fe36249c62b src/lib-compression/istream-lz4.c --- a/src/lib-compression/istream-lz4.c Wed May 07 12:26:38 2014 +0300 +++ b/src/lib-compression/istream-lz4.c Wed May 07 12:26:58 2014 +0300 @@ -29,7 +29,8 @@ { struct lz4_istream *zstream = (struct lz4_istream *)stream; - buffer_free(&zstream->chunk_buf); + if (zstream->chunk_buf != NULL) + buffer_free(&zstream->chunk_buf); if (close_parent) i_stream_close(zstream->istream.parent); } From dovecot at dovecot.org Wed May 7 10:03:25 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 10:03:25 +0000 Subject: dovecot-2.2: lib-compression: gz compression didn't handle multi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/625249382745 changeset: 17328:625249382745 user: Timo Sirainen date: Wed May 07 12:27:36 2014 +0300 description: lib-compression: gz compression didn't handle multiple flushes correctly. diffstat: src/lib-compression/ostream-zlib.c | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 deletions(-) diffs (93 lines): diff -r 2fe36249c62b -r 625249382745 src/lib-compression/ostream-zlib.c --- a/src/lib-compression/ostream-zlib.c Wed May 07 12:26:58 2014 +0300 +++ b/src/lib-compression/ostream-zlib.c Wed May 07 12:27:36 2014 +0300 @@ -141,12 +141,18 @@ } } - switch (deflate(zs, flush)) { + ret = deflate(zs, flush); + switch (ret) { case Z_OK: case Z_BUF_ERROR: break; + case Z_STREAM_ERROR: + i_assert(zstream->gz); + i_panic("zlib.write(%s) failed: Can't write more data to .gz after flushing", + o_stream_get_name(&zstream->ostream.ostream)); default: - i_unreached(); + i_panic("zlib.write(%s) failed with unexpected code %d", + o_stream_get_name(&zstream->ostream.ostream), ret); } } size -= zs->avail_in; @@ -158,12 +164,13 @@ return size; } -static int o_stream_zlib_send_flush(struct zlib_ostream *zstream) +static int +o_stream_zlib_send_flush(struct zlib_ostream *zstream, bool final) { z_stream *zs = &zstream->zs; unsigned int len; bool done = FALSE; - int ret; + int ret, flush; if (zs->avail_in != 0) { i_assert(zstream->ostream.ostream.last_failed_errno != 0); @@ -182,6 +189,9 @@ if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0) return ret; + flush = !zstream->gz ? Z_SYNC_FLUSH : + (final ? Z_FINISH : Z_NO_FLUSH); + i_assert(zstream->outbuf_used == 0); do { len = sizeof(zstream->outbuf) - zs->avail_out; @@ -196,7 +206,7 @@ break; } - switch (deflate(zs, zstream->gz ? Z_FINISH : Z_SYNC_FLUSH)) { + switch (deflate(zs, flush)) { case Z_OK: case Z_BUF_ERROR: break; @@ -208,9 +218,12 @@ } } while (zs->avail_out != sizeof(zstream->outbuf)); - if (o_stream_zlib_send_gz_trailer(zstream) < 0) - return -1; - zstream->flushed = TRUE; + if (final) { + if (o_stream_zlib_send_gz_trailer(zstream) < 0) + return -1; + } + if (final || flush != Z_NO_FLUSH) + zstream->flushed = TRUE; return 0; } @@ -219,7 +232,7 @@ struct zlib_ostream *zstream = (struct zlib_ostream *)stream; int ret; - if (o_stream_zlib_send_flush(zstream) < 0) + if (o_stream_zlib_send_flush(zstream, TRUE) < 0) return -1; ret = o_stream_flush(stream->parent); @@ -254,7 +267,7 @@ stream->ostream.offset += bytes; if (!zstream->ostream.corked && i == iov_count) { - if (o_stream_zlib_send_flush(zstream) < 0) + if (o_stream_zlib_send_flush(zstream, FALSE) < 0) return -1; } /* avail_in!=0 check is used to detect errors. if it's non-zero here From dovecot at dovecot.org Wed May 7 10:03:26 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 10:03:26 +0000 Subject: dovecot-2.2: lib-compression: Added some unit testing for lib-co... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6b40179a6868 changeset: 17329:6b40179a6868 user: Timo Sirainen date: Wed May 07 13:01:17 2014 +0300 description: lib-compression: Added some unit testing for lib-compression. Not perfect in any way, but at least tests if things are completely broken. diffstat: src/lib-compression/Makefile.am | 21 ++++ src/lib-compression/test-compression.c | 171 +++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+), 0 deletions(-) diffs (203 lines): diff -r 625249382745 -r 6b40179a6868 src/lib-compression/Makefile.am --- a/src/lib-compression/Makefile.am Wed May 07 12:27:36 2014 +0300 +++ b/src/lib-compression/Makefile.am Wed May 07 13:01:17 2014 +0300 @@ -29,3 +29,24 @@ libdovecot_compression_la_LIBADD = libcompression.la ../lib/liblib.la $(COMPRESS_LIBS) libdovecot_compression_la_DEPENDENCIES = libcompression.la libdovecot_compression_la_LDFLAGS = -export-dynamic + +test_programs = \ + test-compression + +noinst_PROGRAMS = $(test_programs) + +test_libs = \ + $(noinst_LTLIBRARIES) \ + ../lib-test/libtest.la \ + ../lib/liblib.la +test_deps = $(test_libs) + +test_compression_SOURCES = test-compression.c +test_compression_LDADD = $(test_libs) +test_compression_DEPENDENCIES = $(test_deps) + +check: check-am check-test +check-test: all-am + for bin in $(test_programs); do \ + if ! $(RUN_TEST) ./$$bin; then exit 1; fi; \ + done diff -r 625249382745 -r 6b40179a6868 src/lib-compression/test-compression.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-compression/test-compression.c Wed May 07 13:01:17 2014 +0300 @@ -0,0 +1,171 @@ +/* Copyright (c) 2014 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "istream.h" +#include "ostream.h" +#include "sha1.h" +#include "randgen.h" +#include "test-common.h" +#include "compression.h" + +#include +#include +#include + +static void test_compression_handler(const struct compression_handler *handler) +{ + const char *path = "test-compression.tmp"; + struct istream *file_input, *input; + struct ostream *file_output, *output; + unsigned char buf[IO_BLOCK_SIZE]; + const unsigned char *data; + size_t size; + struct sha1_ctxt sha1; + unsigned char output_sha1[SHA1_RESULTLEN], input_sha1[SHA1_RESULTLEN]; + unsigned int i; + int fd; + ssize_t ret; + + test_begin(t_strdup_printf("compression handler %s", handler->name)); + + /* write compressed data */ + fd = open(path, O_TRUNC | O_CREAT | O_RDWR, 0600); + if (fd == -1) + i_fatal("creat(%s) failed: %m", path); + file_output = o_stream_create_fd_file(fd, 0, FALSE); + output = handler->create_ostream(file_output, 1); + sha1_init(&sha1); + + /* 1) write lots of easily compressible data */ + memset(buf, 0, sizeof(buf)); + for (i = 0; i < 1024*1024*4 / sizeof(buf); i++) { + sha1_loop(&sha1, buf, sizeof(buf)); + test_assert(o_stream_send(output, buf, sizeof(buf)) == sizeof(buf)); + } + + /* 2) write uncompressible data */ + for (i = 0; i < 1024*128 / sizeof(buf); i++) { + random_fill_weak(buf, sizeof(buf)); + sha1_loop(&sha1, buf, sizeof(buf)); + test_assert(o_stream_send(output, buf, sizeof(buf)) == sizeof(buf)); + } + + /* 3) write semi-compressible data */ + for (i = 0; i < sizeof(buf); i++) { + if (rand () % 3 == 0) + buf[i] = rand() % 4; + else + buf[i] = i; + } + for (i = 0; i < 1024*128 / sizeof(buf); i++) { + sha1_loop(&sha1, buf, sizeof(buf)); + test_assert(o_stream_send(output, buf, sizeof(buf)) == sizeof(buf)); + } + + o_stream_destroy(&output); + o_stream_destroy(&file_output); + sha1_result(&sha1, output_sha1); + + /* read and uncompress the data */ + sha1_init(&sha1); + file_input = i_stream_create_fd(fd, IO_BLOCK_SIZE, FALSE); + input = handler->create_istream(file_input, FALSE); + while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) { + sha1_loop(&sha1, data, size); + i_stream_skip(input, size); + } + test_assert(ret == -1); + i_stream_destroy(&input); + i_stream_destroy(&file_input); + sha1_result(&sha1, input_sha1); + + test_assert(memcmp(input_sha1, output_sha1, sizeof(input_sha1)) == 0); + if (unlink(path) < 0) + i_error("unlink(%s) failed: %m", path); + + test_end(); +} + +static void test_compression(void) +{ + unsigned int i; + + for (i = 0; compression_handlers[i].name != NULL; i++) { + if (compression_handlers[i].create_istream != NULL) + test_compression_handler(&compression_handlers[i]); + } +} + +static void test_compress_file(const char *in_path, const char *out_path) +{ + const struct compression_handler *handler; + struct istream *input, *file_input; + struct ostream *output, *file_output; + int fd_in, fd_out; + struct sha1_ctxt sha1; + unsigned char output_sha1[SHA1_RESULTLEN], input_sha1[SHA1_RESULTLEN]; + const unsigned char *data; + size_t size; + ssize_t ret; + + handler = compression_lookup_handler_from_ext(out_path); + if (handler == NULL) + i_fatal("Can't detect compression algorithm from path %s", out_path); + if (handler->create_ostream == NULL) + i_fatal("Support not compiled in for %s", handler->name); + + /* write the compressed output file */ + fd_in = open(in_path, O_RDONLY); + if (fd_in == -1) + i_fatal("open(%s) failed: %m", in_path); + fd_out = open(out_path, O_TRUNC | O_CREAT | O_RDWR, 0600); + if (fd_out == -1) + i_fatal("creat(%s) failed: %m", out_path); + + sha1_init(&sha1); + file_output = o_stream_create_fd_file(fd_out, 0, FALSE); + output = handler->create_ostream(file_output, 1); + input = i_stream_create_fd(fd_in, IO_BLOCK_SIZE, TRUE); + while (i_stream_read_data(input, &data, &size, 0) > 0) { + sha1_loop(&sha1, data, size); + o_stream_nsend(output, data, size); + i_stream_skip(input, size); + } + if (o_stream_nfinish(output) < 0) { + i_fatal("write(%s) failed: %s", + out_path, o_stream_get_error(output)); + } + i_stream_destroy(&input); + o_stream_destroy(&output); + o_stream_destroy(&file_output); + sha1_result(&sha1, output_sha1); + + /* verify that we can read the compressed file */ + sha1_init(&sha1); + file_input = i_stream_create_fd(fd_out, IO_BLOCK_SIZE, FALSE); + input = handler->create_istream(file_input, FALSE); + while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) { + sha1_loop(&sha1, data, size); + i_stream_skip(input, size); + } + i_stream_destroy(&input); + i_stream_destroy(&file_input); + sha1_result(&sha1, input_sha1); + + if (memcmp(input_sha1, output_sha1, sizeof(input_sha1)) != 0) + i_fatal("Decompression couldn't get the original input"); + i_close_fd(&fd_out); +} + +int main(int argc, char *argv[]) +{ + static void (*test_functions[])(void) = { + test_compression, + NULL + }; + if (argc == 3) { + test_compress_file(argv[1], argv[2]); + return 0; + } + return test_run(test_functions); +} From dovecot at dovecot.org Wed May 7 10:03:26 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 10:03:26 +0000 Subject: dovecot-2.2: liblib: Added unit test for hash methods to make su... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2e7ac48c6072 changeset: 17330:2e7ac48c6072 user: Timo Sirainen date: Wed May 07 13:02:29 2014 +0300 description: liblib: Added unit test for hash methods to make sure they don't do read access beyond buffer. This currently fails for MD4 and MD5, so they need to be fixed/replaced.. diffstat: src/lib/Makefile.am | 1 + src/lib/test-hash-method.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/lib/test-lib.c | 1 + src/lib/test-lib.h | 1 + 4 files changed, 46 insertions(+), 0 deletions(-) diffs (80 lines): diff -r 6b40179a6868 -r 2e7ac48c6072 src/lib/Makefile.am --- a/src/lib/Makefile.am Wed May 07 13:01:17 2014 +0300 +++ b/src/lib/Makefile.am Wed May 07 13:02:29 2014 +0300 @@ -275,6 +275,7 @@ test-buffer.c \ test-crc32.c \ test-hash-format.c \ + test-hash-method.c \ test-hex-binary.c \ test-iso8601-date.c \ test-istream-base64-decoder.c \ diff -r 6b40179a6868 -r 2e7ac48c6072 src/lib/test-hash-method.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/test-hash-method.c Wed May 07 13:02:29 2014 +0300 @@ -0,0 +1,43 @@ +/* Copyright (c) 2014 Dovecot authors, see the included COPYING file */ + +#include "test-lib.h" +#include "mmap-util.h" +#include "hash-method.h" + +static unsigned char *buf; +static unsigned int buf_size; + +static void test_hash_method_one(const struct hash_method *method) +{ + unsigned char *ctx, *digest; + unsigned int i; + + test_begin(t_strdup_printf("hash method %s", method->name)); + + ctx = i_malloc(method->context_size); + digest = i_malloc(method->digest_size); + method->init(ctx); + + /* make sure the code doesn't try to access data past boundaries */ + for (i = 0; i < buf_size; i++) + method->loop(ctx, buf + buf_size - i, i); + method->result(ctx, digest); + + i_free(ctx); + i_free(digest); + test_end(); +} + +void test_hash_method(void) +{ + unsigned int i; + + buf_size = mmap_get_page_size(); + buf = mmap(NULL, buf_size*2, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + mprotect(buf + buf_size, buf_size, PROT_NONE); + memset(buf, 0, buf_size); + + for (i = 0; hash_methods[i] != NULL; i++) + test_hash_method_one(hash_methods[i]); +} diff -r 6b40179a6868 -r 2e7ac48c6072 src/lib/test-lib.c --- a/src/lib/test-lib.c Wed May 07 13:01:17 2014 +0300 +++ b/src/lib/test-lib.c Wed May 07 13:02:29 2014 +0300 @@ -12,6 +12,7 @@ test_buffer, test_crc32, test_hash_format, + test_hash_method, test_hex_binary, test_iso8601_date, test_istream_base64_decoder, diff -r 6b40179a6868 -r 2e7ac48c6072 src/lib/test-lib.h --- a/src/lib/test-lib.h Wed May 07 13:01:17 2014 +0300 +++ b/src/lib/test-lib.h Wed May 07 13:02:29 2014 +0300 @@ -11,6 +11,7 @@ void test_buffer(void); void test_crc32(void); void test_hash_format(void); +void test_hash_method(void); void test_hex_binary(void); void test_iso8601_date(void); void test_istream_base64_decoder(void); From dovecot at dovecot.org Wed May 7 13:37:36 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 13:37:36 +0000 Subject: dovecot-2.2: mdbox: Fixed race condition when creating a new mai... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ed6e472cab0e changeset: 17331:ed6e472cab0e user: Timo Sirainen date: Wed May 07 16:36:54 2014 +0300 description: mdbox: Fixed race condition when creating a new mailbox and another process getting its GUID. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 14 +++++++++++--- src/lib-storage/index/dbox-common/dbox-storage.h | 2 ++ src/lib-storage/index/dbox-multi/mdbox-storage.c | 12 ++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diffs (73 lines): diff -r 2e7ac48c6072 -r ed6e472cab0e src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Wed May 07 13:02:29 2014 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Wed May 07 16:36:54 2014 +0300 @@ -255,9 +255,6 @@ const struct mailbox_update *update, bool directory) { struct dbox_storage *storage = (struct dbox_storage *)box->storage; - struct mail_index_sync_ctx *sync_ctx; - struct mail_index_view *view; - struct mail_index_transaction *trans; const char *alt_path; struct stat st; int ret; @@ -290,6 +287,17 @@ } /* dir is empty, ignore it */ } + return dbox_mailbox_create_indexes(box, update); +} + +int dbox_mailbox_create_indexes(struct mailbox *box, + const struct mailbox_update *update) +{ + struct dbox_storage *storage = (struct dbox_storage *)box->storage; + struct mail_index_sync_ctx *sync_ctx; + struct mail_index_view *view; + struct mail_index_transaction *trans; + int ret; /* use syncing as a lock */ ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans, 0); diff -r 2e7ac48c6072 -r ed6e472cab0e src/lib-storage/index/dbox-common/dbox-storage.h --- a/src/lib-storage/index/dbox-common/dbox-storage.h Wed May 07 13:02:29 2014 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.h Wed May 07 16:36:54 2014 +0300 @@ -73,6 +73,8 @@ int dbox_mailbox_open(struct mailbox *box); int dbox_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory); +int dbox_mailbox_create_indexes(struct mailbox *box, + const struct mailbox_update *update); int dbox_verify_alt_storage(struct mailbox_list *list); bool dbox_header_have_flag(struct mailbox *box, uint32_t ext_id, unsigned int flags_offset, uint8_t flag); diff -r 2e7ac48c6072 -r ed6e472cab0e src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed May 07 13:02:29 2014 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed May 07 16:36:54 2014 +0300 @@ -379,10 +379,15 @@ /* there's a race condition between mkdir and getting the mailbox GUID. normally this is handled by mdbox syncing, but GUID can be looked up - without syncing. when mbox->creating=TRUE, the errors are hidden - and we'll simply finish the mailbox creation */ + without syncing. when we detect this situation we'll try to finish + creating the indexes first, which usually means just waiting for + the sync lock to get unlocked by the other process creating them. */ idx_hdr = mail_index_get_header(mbox->box.view); - mbox->creating = idx_hdr->uid_validity == 0 && idx_hdr->next_uid == 1; + if (idx_hdr->uid_validity == 0 && idx_hdr->next_uid == 1) { + if (dbox_mailbox_create_indexes(&mbox->box, NULL) < 0) + return -1; + } + if (mdbox_read_header(mbox, &hdr, &need_resize) < 0) memset(&hdr, 0, sizeof(hdr)); @@ -394,7 +399,6 @@ } if (ret == 0) memcpy(guid_r, hdr.mailbox_guid, GUID_128_SIZE); - mbox->creating = FALSE; return ret; } From dovecot at dovecot.org Wed May 7 13:42:13 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 13:42:13 +0000 Subject: dovecot-2.2: lib-storage: Fixed assert-crash when looking up pri... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/774e486a94ab changeset: 17332:774e486a94ab user: Timo Sirainen date: Wed May 07 16:41:34 2014 +0300 description: lib-storage: Fixed assert-crash when looking up private flags for a mail being saved. diffstat: src/lib-storage/index/index-mail.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r ed6e472cab0e -r 774e486a94ab src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Wed May 07 16:36:54 2014 +0300 +++ b/src/lib-storage/index/index-mail.c Wed May 07 16:41:34 2014 +0300 @@ -153,6 +153,11 @@ /* no private view (set by view syncing) -> no private flags */ return FALSE; } + if (_mail->saving) { + /* mail is still being saved, it has no private flags yet */ + return FALSE; + } + i_assert(_mail->uid != 0); index_transaction_init_pvt(_mail->transaction); if (!mail_index_lookup_seq(_mail->transaction->view_pvt, _mail->uid, From dovecot at dovecot.org Wed May 7 14:12:54 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 14:12:54 +0000 Subject: dovecot-2.2: acl: Global ACL file used only the first matching r... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7a08a481c133 changeset: 17333:7a08a481c133 user: Timo Sirainen date: Wed May 07 17:12:19 2014 +0300 description: acl: Global ACL file used only the first matching rights line, not merging all the matches. diffstat: src/plugins/acl/acl-global-file.c | 45 +++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 25 deletions(-) diffs (61 lines): diff -r 774e486a94ab -r 7a08a481c133 src/plugins/acl/acl-global-file.c --- a/src/plugins/acl/acl-global-file.c Wed May 07 16:41:34 2014 +0300 +++ b/src/plugins/acl/acl-global-file.c Wed May 07 17:12:19 2014 +0300 @@ -155,8 +155,24 @@ return 0; } -static struct acl_global_rights * -acl_global_file_find_rights(struct acl_global_file *file, const char *vname) +void acl_global_file_get(struct acl_global_file *file, const char *vname, + pool_t pool, ARRAY_TYPE(acl_rights) *rights_r) +{ + struct acl_global_rights *global_rights; + const struct acl_rights *rights; + struct acl_rights *new_rights; + + array_foreach_modifiable(&file->rights, global_rights) { + if (!wildcard_match(vname, global_rights->vpattern)) + continue; + array_foreach(&global_rights->rights, rights) { + new_rights = array_append_space(rights_r); + acl_rights_dup(rights, pool, new_rights); + } + } +} + +bool acl_global_file_have_any(struct acl_global_file *file, const char *vname) { struct acl_global_rights *rights; @@ -164,28 +180,7 @@ array_foreach_modifiable(&file->rights, rights) { if (wildcard_match(vname, rights->vpattern)) - return rights; + return TRUE; } - return NULL; + return FALSE; } - -void acl_global_file_get(struct acl_global_file *file, const char *vname, - pool_t pool, ARRAY_TYPE(acl_rights) *rights_r) -{ - struct acl_global_rights *global_rights; - const struct acl_rights *rights; - struct acl_rights *new_rights; - - global_rights = acl_global_file_find_rights(file, vname); - if (global_rights == NULL) - return; - array_foreach(&global_rights->rights, rights) { - new_rights = array_append_space(rights_r); - acl_rights_dup(rights, pool, new_rights); - } -} - -bool acl_global_file_have_any(struct acl_global_file *file, const char *vname) -{ - return acl_global_file_find_rights(file, vname) != NULL; -} From dovecot at dovecot.org Wed May 7 14:26:59 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 14:26:59 +0000 Subject: dovecot-2.2: *-login: SSL connections didn't get closed when the... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/41622541a7a3 changeset: 17334:41622541a7a3 user: Timo Sirainen date: Wed May 07 17:26:21 2014 +0300 description: *-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/login-common/client-common.c | 2 ++ src/login-common/ssl-proxy-openssl.c | 3 +-- src/login-common/ssl-proxy.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diffs (43 lines): diff -r 7a08a481c133 -r 41622541a7a3 src/login-common/client-common.c --- a/src/login-common/client-common.c Wed May 07 17:12:19 2014 +0300 +++ b/src/login-common/client-common.c Wed May 07 17:26:21 2014 +0300 @@ -171,6 +171,8 @@ last_client = client->prev; DLLIST_REMOVE(&clients, client); + if (!client->login_success && client->ssl_proxy != NULL) + ssl_proxy_destroy(client->ssl_proxy); if (client->input != NULL) i_stream_close(client->input); if (client->output != NULL) diff -r 7a08a481c133 -r 41622541a7a3 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed May 07 17:12:19 2014 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Wed May 07 17:26:21 2014 +0300 @@ -116,7 +116,6 @@ static void ssl_read(struct ssl_proxy *proxy); static void ssl_write(struct ssl_proxy *proxy); static void ssl_step(struct ssl_proxy *proxy); -static void ssl_proxy_destroy(struct ssl_proxy *proxy); static void ssl_proxy_unref(struct ssl_proxy *proxy); static struct ssl_server_context * @@ -807,7 +806,7 @@ i_free(proxy); } -static void ssl_proxy_destroy(struct ssl_proxy *proxy) +void ssl_proxy_destroy(struct ssl_proxy *proxy) { if (proxy->destroyed) return; diff -r 7a08a481c133 -r 41622541a7a3 src/login-common/ssl-proxy.h --- a/src/login-common/ssl-proxy.h Wed May 07 17:12:19 2014 +0300 +++ b/src/login-common/ssl-proxy.h Wed May 07 17:26:21 2014 +0300 @@ -34,6 +34,7 @@ const char *ssl_proxy_get_security_string(struct ssl_proxy *proxy); const char *ssl_proxy_get_compression(struct ssl_proxy *proxy); const char *ssl_proxy_get_cert_error(struct ssl_proxy *proxy); +void ssl_proxy_destroy(struct ssl_proxy *proxy); void ssl_proxy_free(struct ssl_proxy **proxy); /* Return number of active SSL proxies */ From dovecot at dovecot.org Wed May 7 14:27:57 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 14:27:57 +0000 Subject: dovecot-2.1: *-login: SSL connections didn't get closed when the... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b7ac23b4d339 changeset: 15015:b7ac23b4d339 user: Timo Sirainen date: Wed May 07 17:26:21 2014 +0300 description: *-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/login-common/client-common.c | 2 ++ src/login-common/ssl-proxy-openssl.c | 3 +-- src/login-common/ssl-proxy.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diffs (43 lines): diff -r b20b4071a282 -r b7ac23b4d339 src/login-common/client-common.c --- a/src/login-common/client-common.c Mon Aug 05 14:06:23 2013 +0300 +++ b/src/login-common/client-common.c Wed May 07 17:26:21 2014 +0300 @@ -142,6 +142,8 @@ last_client = client->prev; DLLIST_REMOVE(&clients, client); + if (!client->login_success && client->ssl_proxy != NULL) + ssl_proxy_destroy(client->ssl_proxy); if (client->input != NULL) i_stream_close(client->input); if (client->output != NULL) diff -r b20b4071a282 -r b7ac23b4d339 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Mon Aug 05 14:06:23 2013 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Wed May 07 17:26:21 2014 +0300 @@ -108,7 +108,6 @@ static void ssl_read(struct ssl_proxy *proxy); static void ssl_write(struct ssl_proxy *proxy); static void ssl_step(struct ssl_proxy *proxy); -static void ssl_proxy_destroy(struct ssl_proxy *proxy); static void ssl_proxy_unref(struct ssl_proxy *proxy); static struct ssl_server_context * @@ -783,7 +782,7 @@ i_free(proxy); } -static void ssl_proxy_destroy(struct ssl_proxy *proxy) +void ssl_proxy_destroy(struct ssl_proxy *proxy) { if (proxy->destroyed) return; diff -r b20b4071a282 -r b7ac23b4d339 src/login-common/ssl-proxy.h --- a/src/login-common/ssl-proxy.h Mon Aug 05 14:06:23 2013 +0300 +++ b/src/login-common/ssl-proxy.h Wed May 07 17:26:21 2014 +0300 @@ -31,6 +31,7 @@ const char *ssl_proxy_get_security_string(struct ssl_proxy *proxy); const char *ssl_proxy_get_compression(struct ssl_proxy *proxy); const char *ssl_proxy_get_cert_error(struct ssl_proxy *proxy); +void ssl_proxy_destroy(struct ssl_proxy *proxy); void ssl_proxy_free(struct ssl_proxy **proxy); /* Return number of active SSL proxies */ From dovecot at dovecot.org Wed May 7 16:35:21 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 16:35:21 +0000 Subject: dovecot-2.2: fts-lucene: Don't mix definite + maybe queries for ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4b67da0b86a3 changeset: 17335:4b67da0b86a3 user: Timo Sirainen date: Wed May 07 19:34:42 2014 +0300 description: fts-lucene: Don't mix definite + maybe queries for now, since it returns broken results. diffstat: src/plugins/fts-lucene/lucene-wrapper.cc | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 41622541a7a3 -r 4b67da0b86a3 src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Wed May 07 17:26:21 2014 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Wed May 07 19:34:42 2014 +0300 @@ -1344,6 +1344,13 @@ return -1; } + if (have_definites) { + /* FIXME: mixing up definite + maybe queries is broken. if the + definite query matched, it'll just assume that the maybe + queries matched as well */ + return 0; + } + ARRAY_TYPE(lucene_query) maybe_queries; t_array_init(&maybe_queries, 16); bool have_maybies = false; From dovecot at dovecot.org Wed May 7 16:37:41 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 16:37:41 +0000 Subject: dovecot-2.2: lib: fix md4/md5 buffer read overrun Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fc627348087e changeset: 17336:fc627348087e user: Phil Carmody date: Wed May 07 18:39:23 2014 +0300 description: lib: fix md4/md5 buffer read overrun uint_fast32_t may be 64 bits and read too many bytes at the end of the buffer. This didn't actually break anything as long as there was 32 bits of readable memory past the buffer. diffstat: src/lib/md4.c | 7 +++++-- src/lib/md5.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diffs (29 lines): diff -r 4b67da0b86a3 -r fc627348087e src/lib/md4.c --- a/src/lib/md4.c Wed May 07 19:34:42 2014 +0300 +++ b/src/lib/md4.c Wed May 07 18:39:23 2014 +0300 @@ -43,8 +43,11 @@ * doesn't work. */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define SET(n) \ - (*(const uint_fast32_t *)&ptr[(n) * 4]) +/* uint_fast32_t might be 64 bit, and thus may read 4 more bytes + * beyond the end of the buffer. So only read precisely 32 bits + */ +#define SET(n) \ + (*(const uint32_t *)&ptr[(n) * 4]) #define GET(n) \ SET(n) #else diff -r 4b67da0b86a3 -r fc627348087e src/lib/md5.c --- a/src/lib/md5.c Wed May 07 19:34:42 2014 +0300 +++ b/src/lib/md5.c Wed May 07 18:39:23 2014 +0300 @@ -48,7 +48,7 @@ */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) #define SET(n) \ - (*(const uint_fast32_t *)&ptr[(n) * 4]) + (*(const uint32_t *)&ptr[(n) * 4]) #define GET(n) \ SET(n) #else From dovecot at dovecot.org Wed May 7 16:47:54 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 16:47:54 +0000 Subject: dovecot-2.2: lib-imap: IMAP parser didn't parse atoms correctly ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8568cacb0d03 changeset: 17337:8568cacb0d03 user: Timo Sirainen date: Wed May 07 19:47:12 2014 +0300 description: lib-imap: IMAP parser didn't parse atoms correctly that started with '~' character. literal8 begins only after "~{", not immediately after "~" which is a valid ATOM-CHAR. diffstat: src/lib-imap/imap-parser.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diffs (19 lines): diff -r fc627348087e -r 8568cacb0d03 src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Wed May 07 18:39:23 2014 +0300 +++ b/src/lib-imap/imap-parser.c Wed May 07 19:47:12 2014 +0300 @@ -594,6 +594,15 @@ parser->str_first_escape = -1; break; case '~': + /* This could be either literal8 or atom */ + if (data_size == 1) { + /* wait for the next char */ + return FALSE; + } + if (data[1] != '{') { + parser->cur_type = ARG_PARSE_ATOM; + break; + } if ((parser->flags & IMAP_PARSE_FLAG_LITERAL8) == 0) { parser->error = "literal8 not allowed here"; return FALSE; From dovecot at dovecot.org Wed May 7 17:15:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 17:15:15 +0000 Subject: dovecot-2.2: doveadm: table formatter printed header unaligned i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/21f9679214ac changeset: 17338:21f9679214ac user: Timo Sirainen date: Wed May 07 20:14:32 2014 +0300 description: doveadm: table formatter printed header unaligned if it had hidden titles. This was broken by the previous table formatter change. diffstat: src/doveadm/doveadm-print-table.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 8568cacb0d03 -r 21f9679214ac src/doveadm/doveadm-print-table.c --- a/src/doveadm/doveadm-print-table.c Wed May 07 19:47:12 2014 +0300 +++ b/src/doveadm/doveadm-print-table.c Wed May 07 20:14:32 2014 +0300 @@ -148,7 +148,7 @@ } if (i == count) return; - for (; i < count; i++) { + for (i = 0; i < count; i++) { if (i > 0) fprintf(stderr, " "); if ((headers[i].flags & From dovecot at dovecot.org Wed May 7 17:22:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 17:22:23 +0000 Subject: dovecot-2.2: pop3: Remove dead assignment detected by scan-build. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/78fd8b7d25e9 changeset: 17339:78fd8b7d25e9 user: Teemu Huovila date: Wed May 07 20:18:39 2014 +0300 description: pop3: Remove dead assignment detected by scan-build. diffstat: src/pop3/pop3-commands.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 21f9679214ac -r 78fd8b7d25e9 src/pop3/pop3-commands.c --- a/src/pop3/pop3-commands.c Wed May 07 20:14:32 2014 +0300 +++ b/src/pop3/pop3-commands.c Wed May 07 20:18:39 2014 +0300 @@ -269,7 +269,6 @@ ctx = mailbox_search_init(client->trans, search_args, NULL, 0, NULL); mail_search_args_unref(&search_args); - msgnum = 0; while (mailbox_search_next(ctx, &mail)) { if (seq_range_exists(&deleted_msgs, mail->seq)) client_expunge(client, mail); From dovecot at dovecot.org Wed May 7 17:22:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 17:22:23 +0000 Subject: dovecot-2.2: lib-index: Fixed detecting broken strmap index file... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0e8ddc1bfe8d changeset: 17340:0e8ddc1bfe8d user: Teemu Huovila date: Wed May 07 20:21:02 2014 +0300 description: lib-index: Fixed detecting broken strmap index file (thread index). diffstat: src/lib-index/mail-index-strmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 78fd8b7d25e9 -r 0e8ddc1bfe8d src/lib-index/mail-index-strmap.c --- a/src/lib-index/mail-index-strmap.c Wed May 07 20:18:39 2014 +0300 +++ b/src/lib-index/mail-index-strmap.c Wed May 07 20:21:02 2014 +0300 @@ -561,7 +561,7 @@ /* this block is done */ return 0; } - if (mail_index_strmap_read_packed(ctx, &uid_diff) < 0) + if (mail_index_strmap_read_packed(ctx, &uid_diff) <= 0) return -1; ctx->rec.uid += uid_diff; From dovecot at dovecot.org Wed May 7 17:24:56 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 17:24:56 +0000 Subject: dovecot-2.2: auth: LDAP errors may have crashed the auth process. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f32e7ca24292 changeset: 17341:f32e7ca24292 user: Timo Sirainen date: Wed May 07 20:24:05 2014 +0300 description: auth: LDAP errors may have crashed the auth process. diffstat: src/auth/db-ldap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0e8ddc1bfe8d -r f32e7ca24292 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Wed May 07 20:21:02 2014 +0300 +++ b/src/auth/db-ldap.c Wed May 07 20:24:05 2014 +0300 @@ -816,7 +816,7 @@ if (res != NULL && srequest != NULL && srequest->result != NULL) request->callback(conn, request, srequest->result->msg); - request->callback(conn, request, res->msg); + request->callback(conn, request, res == NULL ? NULL : res->msg); } T_END; if (idx > 0) { From pigeonhole at rename-it.nl Wed May 7 18:03:29 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 07 May 2014 20:03:29 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: Added final result execution ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/3476d8bc0dc3 changeset: 1852:3476d8bc0dc3 user: Stephan Bosch date: Wed May 07 20:03:10 2014 +0200 description: lib-sieve: Added final result execution stage for the duplicate extension. This way, a duplicate is only marked when the script execution succeeds, as required in the specification. diffstat: src/lib-sieve/cmd-discard.c | 10 +- src/lib-sieve/cmd-redirect.c | 15 +- src/lib-sieve/ext-reject.c | 15 +- src/lib-sieve/plugins/duplicate/ext-duplicate-common.c | 44 ++++---- src/lib-sieve/plugins/enotify/cmd-notify.c | 13 +- src/lib-sieve/plugins/notify/cmd-notify.c | 13 +- src/lib-sieve/plugins/vacation/cmd-vacation.c | 15 +- src/lib-sieve/sieve-actions.c | 19 +-- src/lib-sieve/sieve-actions.h | 10 +- src/lib-sieve/sieve-result.c | 82 +++++++++++------ src/plugins/sieve-extprograms/cmd-pipe.c | 14 +- 11 files changed, 124 insertions(+), 126 deletions(-) diffs (truncated from 424 to 300 lines): diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/cmd-discard.c --- a/src/lib-sieve/cmd-discard.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/cmd-discard.c Wed May 07 20:03:10 2014 +0200 @@ -63,13 +63,9 @@ const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); const struct sieve_action_def act_discard = { - "discard", - 0, - NULL, NULL, NULL, - act_discard_print, - NULL, NULL, - act_discard_commit, - NULL + .name = "discard", + .print = act_discard_print, + .commit = act_discard_commit, }; /* diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/cmd-redirect.c Wed May 07 20:03:10 2014 +0200 @@ -92,15 +92,12 @@ void *tr_context, bool *keep); const struct sieve_action_def act_redirect = { - "redirect", - SIEVE_ACTFLAG_TRIES_DELIVER, - act_redirect_equals, - act_redirect_check_duplicate, - NULL, - act_redirect_print, - NULL, NULL, - act_redirect_commit, - NULL + .name = "redirect", + .flags = SIEVE_ACTFLAG_TRIES_DELIVER, + .equals = act_redirect_equals, + .check_duplicate = act_redirect_check_duplicate, + .print = act_redirect_print, + .commit = act_redirect_commit }; struct act_redirect_context { diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/ext-reject.c --- a/src/lib-sieve/ext-reject.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/ext-reject.c Wed May 07 20:03:10 2014 +0200 @@ -186,15 +186,12 @@ const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); const struct sieve_action_def act_reject = { - "reject", - SIEVE_ACTFLAG_SENDS_RESPONSE, - NULL, - act_reject_check_duplicate, - act_reject_check_conflict, - act_reject_print, - NULL, NULL, - act_reject_commit, - NULL + .name = "reject", + .flags = SIEVE_ACTFLAG_SENDS_RESPONSE, + .check_duplicate = act_reject_check_duplicate, + .check_conflict = act_reject_check_conflict, + .print = act_reject_print, + .commit = act_reject_commit, }; struct act_reject_context { diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/plugins/duplicate/ext-duplicate-common.c --- a/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c Wed May 07 20:03:10 2014 +0200 @@ -15,6 +15,7 @@ #include "sieve-message.h" #include "sieve-code.h" #include "sieve-runtime.h" +#include "sieve-interpreter.h" #include "sieve-actions.h" #include "sieve-result.h" @@ -78,18 +79,14 @@ static void act_duplicate_mark_print (const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static int act_duplicate_mark_commit +static void act_duplicate_mark_finish (const struct sieve_action *action, - const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); + const struct sieve_action_exec_env *aenv, void *tr_context, int status); static const struct sieve_action_def act_duplicate_mark = { - "duplicate_mark", - 0, - NULL, NULL, NULL, - act_duplicate_mark_print, - NULL, NULL, - act_duplicate_mark_commit, - NULL + .name = "duplicate_mark", + .print = act_duplicate_mark_print, + .finish = act_duplicate_mark_finish }; static void act_duplicate_mark_print @@ -108,27 +105,24 @@ } } -// FIXME: at commit phase the sieve script is still not guaranteed to finish -// successfully. We need a new final stage in Sieve result execution. -static int act_duplicate_mark_commit +static void act_duplicate_mark_finish (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, - void *tr_context ATTR_UNUSED, bool *keep ATTR_UNUSED) + void *tr_context ATTR_UNUSED, int status) { const struct sieve_script_env *senv = aenv->scriptenv; struct act_duplicate_mark_data *data = (struct act_duplicate_mark_data *) action->context; - /* Message was handled successfully until now, so track duplicate for this - * message. - */ - sieve_action_duplicate_mark - (senv, data->hash, sizeof(data->hash), ioloop_time + data->period); - - return SIEVE_EXEC_OK; + if ( status == SIEVE_EXEC_OK ) { + /* Message was handled successfully, so track duplicate for this + * message. + */ + sieve_action_duplicate_mark + (senv, data->hash, sizeof(data->hash), ioloop_time + data->period); + } } - /* * Duplicate checking */ @@ -181,7 +175,13 @@ pool_t msg_pool = NULL, result_pool = NULL; struct act_duplicate_mark_data *act; - if ( !sieve_action_duplicate_check_available(senv) || value == NULL ) + if ( !sieve_action_duplicate_check_available(senv) ) { + sieve_runtime_warning(renv, NULL, "duplicate test: " + "duplicate checking not available in this context"); + return 0; + } + + if ( value == NULL ) return 0; /* Get context; find out whether duplicate was checked earlier */ diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/plugins/enotify/cmd-notify.c --- a/src/lib-sieve/plugins/enotify/cmd-notify.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/plugins/enotify/cmd-notify.c Wed May 07 20:03:10 2014 +0200 @@ -143,15 +143,10 @@ /* Action object */ const struct sieve_action_def act_notify = { - "notify", - 0, - NULL, - act_notify_check_duplicate, - NULL, - act_notify_print, - NULL, NULL, - act_notify_commit, - NULL + .name = "notify", + .check_duplicate =act_notify_check_duplicate, + .print = act_notify_print, + .commit = act_notify_commit, }; /* diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/plugins/notify/cmd-notify.c --- a/src/lib-sieve/plugins/notify/cmd-notify.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/plugins/notify/cmd-notify.c Wed May 07 20:03:10 2014 +0200 @@ -153,15 +153,10 @@ /* Action object */ const struct sieve_action_def act_notify_old = { - "notify", - 0, - NULL, - act_notify_check_duplicate, - NULL, - act_notify_print, - NULL, NULL, - act_notify_commit, - NULL + .name = "notify", + .check_duplicate = act_notify_check_duplicate, + .print = act_notify_print, + .commit = act_notify_commit }; /* diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/plugins/vacation/cmd-vacation.c --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Wed May 07 20:03:10 2014 +0200 @@ -197,15 +197,12 @@ /* Action object */ const struct sieve_action_def act_vacation = { - "vacation", - SIEVE_ACTFLAG_SENDS_RESPONSE, - NULL, - act_vacation_check_duplicate, - act_vacation_check_conflict, - act_vacation_print, - NULL, NULL, - act_vacation_commit, - NULL + .name = "vacation", + .flags = SIEVE_ACTFLAG_SENDS_RESPONSE, + .check_duplicate = act_vacation_check_duplicate, + .check_conflict = act_vacation_check_conflict, + .print = act_vacation_print, + .commit = act_vacation_commit }; /* Action context information */ diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/sieve-actions.c --- a/src/lib-sieve/sieve-actions.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/sieve-actions.c Wed May 07 20:03:10 2014 +0200 @@ -206,16 +206,15 @@ /* Action object */ const struct sieve_action_def act_store = { - "store", - SIEVE_ACTFLAG_TRIES_DELIVER, - act_store_equals, - act_store_check_duplicate, - NULL, - act_store_print, - act_store_start, - act_store_execute, - act_store_commit, - act_store_rollback, + .name = "store", + .flags = SIEVE_ACTFLAG_TRIES_DELIVER, + .equals = act_store_equals, + .check_duplicate = act_store_check_duplicate, + .print = act_store_print, + .start = act_store_start, + .execute = act_store_execute, + .commit = act_store_commit, + .rollback = act_store_rollback, }; /* API */ diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/sieve-actions.h --- a/src/lib-sieve/sieve-actions.h Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/sieve-actions.h Wed May 07 20:03:10 2014 +0200 @@ -77,10 +77,16 @@ const struct sieve_action_exec_env *aenv, void *tr_context); int (*commit) (const struct sieve_action *action, - const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); + const struct sieve_action_exec_env *aenv, void *tr_context, + bool *keep); void (*rollback) (const struct sieve_action *action, - const struct sieve_action_exec_env *aenv, void *tr_context, bool success); + const struct sieve_action_exec_env *aenv, void *tr_context, + bool success); + void (*finish) + (const struct sieve_action *action, + const struct sieve_action_exec_env *aenv, void *tr_context, + int status); }; /* diff -r d1d4454866ad -r 3476d8bc0dc3 src/lib-sieve/sieve-result.c --- a/src/lib-sieve/sieve-result.c Mon May 05 17:09:10 2014 +0200 +++ b/src/lib-sieve/sieve-result.c Wed May 07 20:03:10 2014 +0200 @@ -1002,7 +1002,7 @@ } } - /* Finish keep action */ + /* Commit keep action */ if ( status == SIEVE_EXEC_OK ) { bool dummy = TRUE; @@ -1020,14 +1020,18 @@ (sef, &act_keep, &result->action_env, tr_context, &keep); rsef = rsef->next; } - - return status; + } else { + /* Failed, rollback */ + if ( act_keep.def->rollback != NULL ) From pigeonhole at rename-it.nl Wed May 7 18:15:44 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 07 May 2014 20:15:44 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: Fixed indenting problem in ru... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/24cc301db1b3 changeset: 1853:24cc301db1b3 user: Stephan Bosch date: Wed May 07 20:15:07 2014 +0200 description: lib-sieve: Fixed indenting problem in runtime trace output. Also cleaned up the surrounding code a bit. diffstat: src/lib-sieve/sieve-interpreter.c | 21 ++++++++++++--------- src/lib-sieve/sieve-interpreter.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diffs (54 lines): diff -r 3476d8bc0dc3 -r 24cc301db1b3 src/lib-sieve/sieve-interpreter.c --- a/src/lib-sieve/sieve-interpreter.c Wed May 07 20:03:10 2014 +0200 +++ b/src/lib-sieve/sieve-interpreter.c Wed May 07 20:15:07 2014 +0200 @@ -220,26 +220,29 @@ ehandler, flags); } -void sieve_interpreter_free(struct sieve_interpreter **interp) +void sieve_interpreter_free(struct sieve_interpreter **_interp) { + struct sieve_interpreter *interp = *_interp; + struct sieve_runtime_env *renv = &interp->runenv; const struct sieve_interpreter_extension_reg *eregs; unsigned int ext_count, i; - sieve_runtime_trace_end(&((*interp)->runenv)); + interp->trace.indent = 0; + sieve_runtime_trace_end(renv); /* Signal registered extensions that the interpreter is being destroyed */ - eregs = array_get(&(*interp)->extensions, &ext_count); + eregs = array_get(&interp->extensions, &ext_count); for ( i = 0; i < ext_count; i++ ) { if ( eregs[i].intext != NULL && eregs[i].intext->free != NULL ) - eregs[i].intext->free(eregs[i].ext, *interp, eregs[i].context); + eregs[i].intext->free(eregs[i].ext, interp, eregs[i].context); } - sieve_binary_debug_reader_deinit(&(*interp)->dreader); - sieve_binary_unref(&(*interp)->runenv.sbin); - sieve_error_handler_unref(&(*interp)->runenv.ehandler); + sieve_binary_debug_reader_deinit(&interp->dreader); + sieve_binary_unref(&renv->sbin); + sieve_error_handler_unref(&renv->ehandler); - pool_unref(&((*interp)->pool)); - *interp = NULL; + pool_unref(&interp->pool); + *_interp = NULL; } /* diff -r 3476d8bc0dc3 -r 24cc301db1b3 src/lib-sieve/sieve-interpreter.h --- a/src/lib-sieve/sieve-interpreter.h Wed May 07 20:03:10 2014 +0200 +++ b/src/lib-sieve/sieve-interpreter.h Wed May 07 20:15:07 2014 +0200 @@ -25,7 +25,7 @@ const struct sieve_message_data *msgdata, const struct sieve_script_env *senv, struct sieve_error_handler *ehandler, enum sieve_runtime_flags flags); -void sieve_interpreter_free(struct sieve_interpreter **interp); +void sieve_interpreter_free(struct sieve_interpreter **_interp); /* * Accessors From pigeonhole at rename-it.nl Wed May 7 19:18:02 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 07 May 2014 21:18:02 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: editheader: Made control char... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/dc038c03b376 changeset: 1854:dc038c03b376 user: Stephan Bosch date: Wed May 07 21:17:43 2014 +0200 description: lib-sieve: editheader: Made control characters allowed for editheader, except NUL. NOTE: Dovecot doesn't currently MIME-encode these in the headers. diffstat: src/lib-sieve/plugins/editheader/cmd-addheader.c | 37 ++++++++- tests/extensions/editheader/addheader.svtest | 69 ++++++++++++++++++++ tests/extensions/editheader/errors.svtest | 11 +-- tests/extensions/editheader/errors/field-value.sieve | 6 +- 4 files changed, 107 insertions(+), 16 deletions(-) diffs (200 lines): diff -r 24cc301db1b3 -r dc038c03b376 src/lib-sieve/plugins/editheader/cmd-addheader.c --- a/src/lib-sieve/plugins/editheader/cmd-addheader.c Wed May 07 20:15:07 2014 +0200 +++ b/src/lib-sieve/plugins/editheader/cmd-addheader.c Wed May 07 21:17:43 2014 +0200 @@ -84,6 +84,24 @@ }; /* + * Utility + */ + +static bool _str_contains_nul(const string_t *str) +{ + const unsigned char *p, *pend; + + p = str_data(str); + pend = p + str_len(str); + while (p < pend) { + if (*p == '\0') + return TRUE; + p++; + } + return FALSE; +} + +/* * Validation */ @@ -134,12 +152,18 @@ if ( sieve_argument_is_string_literal(arg) ) { string_t *fvalue = sieve_ast_argument_str(arg); + if ( _str_contains_nul(fvalue) ) { + sieve_argument_validate_error(valdtr, arg, + "addheader command: specified value `%s' is invalid " + "(contains NUL character)", str_sanitize(str_c(fvalue), 80)); + return FALSE; + } + if ( !rfc2822_header_field_body_verify (str_c(fvalue), str_len(fvalue), TRUE, TRUE) ) { - sieve_argument_validate_error(valdtr, arg, + sieve_argument_validate_warning(valdtr, arg, "addheader command: specified value `%s' is invalid", str_sanitize(str_c(fvalue), 80)); - return FALSE; } if ( ext_editheader_header_too_large(cmd->ext, str_len(fvalue)) ) { @@ -281,10 +305,9 @@ return SIEVE_EXEC_OK; } - if ( !rfc2822_header_field_body_verify - (str_c(value), str_len(value), TRUE, TRUE) ) { + if ( _str_contains_nul(value) ) { sieve_runtime_error(renv, NULL, "addheader action: " - "specified value `%s' is invalid", + "specified value `%s' is invalid (contains NUL character)", str_sanitize(str_c(value), 80)); return SIEVE_EXEC_FAILURE; } @@ -304,6 +327,8 @@ str_sanitize(str_c(field_name), 80), str_sanitize(str_c(value), 80)); edmail = sieve_message_edit(renv->msgctx); - edit_mail_header_add(edmail, rfc2822_header_field_name_sanitize(str_c(field_name)), str_c(value), last); + edit_mail_header_add(edmail, + rfc2822_header_field_name_sanitize(str_c(field_name)), + str_c(value), last); return SIEVE_EXEC_OK; } diff -r 24cc301db1b3 -r dc038c03b376 tests/extensions/editheader/addheader.svtest --- a/tests/extensions/editheader/addheader.svtest Wed May 07 20:15:07 2014 +0200 +++ b/tests/extensions/editheader/addheader.svtest Wed May 07 21:17:43 2014 +0200 @@ -1,4 +1,5 @@ require "vnd.dovecot.testsuite"; +require "encoded-character"; require "variables"; require "fileinto"; require "mailbox"; @@ -524,4 +525,72 @@ } } +test_set "message" "${message}"; +test "Addheader - UTF 8" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + addheader "X-Some-Header" "??? ????!"; + fileinto :create "folder4"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder4" 0 { + test_fail "message not stored"; + } + + if not exists "x-some-header" { + test_fail "header not added to stored message"; + } + + if not header :is "x-some-header" "??? ????!" { + if header :matches "x-some-header" "*" {} + test_fail "Bel character not retained: `${0}`"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} + +test_result_reset; + +test_set "message" "${message}"; +test "Addheader - devious characters" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Ring my ${hex:07}!"; + fileinto :create "folder5"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder5" 0 { + test_fail "message not stored"; + } + + if not exists "x-some-header" { + test_fail "header not added to stored message"; + } + + if header :is "x-some-header" "Ring my !" { + if header :matches "x-some-header" "*" {} + test_fail "Bel character not retained: `${0}`"; + } + + if not header :is "x-some-header" "Ring my ${hex:07}!" { + if header :matches "x-some-header" "*" {} + test_fail "Incorrect header value: `${0}`"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} + diff -r 24cc301db1b3 -r dc038c03b376 tests/extensions/editheader/errors.svtest --- a/tests/extensions/editheader/errors.svtest Wed May 07 20:15:07 2014 +0200 +++ b/tests/extensions/editheader/errors.svtest Wed May 07 21:17:43 2014 +0200 @@ -1,6 +1,7 @@ require "vnd.dovecot.testsuite"; require "comparator-i;ascii-numeric"; require "relational"; +require "variables"; require "editheader"; @@ -53,16 +54,12 @@ test_fail "compile should have failed"; } - if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + if not test_error :count "eq" :comparator "i;ascii-numeric" "2" { test_fail "wrong number of errors reported"; } - if not test_error :index 1 :matches "*value*Yeah!?*invalid*" { - test_fail "wrong error reported (1)"; - } - - if not test_error :index 2 :matches "*value*Woah!*invalid*" { - test_fail "wrong error reported (2)"; + if not test_error :index 1 :matches "*value*Woah*invalid*" { + test_fail "wrong error reported (1): ${0}"; } } diff -r 24cc301db1b3 -r dc038c03b376 tests/extensions/editheader/errors/field-value.sieve --- a/tests/extensions/editheader/errors/field-value.sieve Wed May 07 20:15:07 2014 +0200 +++ b/tests/extensions/editheader/errors/field-value.sieve Wed May 07 21:17:43 2014 +0200 @@ -8,8 +8,8 @@ addheader "X-field" "Frop Frml"; -# Invalid 'BELL' -addheader "X-field" "Yeah!${hex:07}"; +# Invalid 'BELL'; but not an error +addheader "X-field" "Yeah${hex:07}!"; # Invalid 'NUL' -addheader "X-field" "Woah!${hex:00}"; +addheader "X-field" "Woah${hex:00}!"; From dovecot at dovecot.org Wed May 7 20:22:56 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 20:22:56 +0000 Subject: dovecot-2.2: auth: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/96660987de96 changeset: 17342:96660987de96 user: Timo Sirainen date: Wed May 07 23:22:13 2014 +0300 description: auth: Minor code cleanup diffstat: src/auth/mech-rpa.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (13 lines): diff -r f32e7ca24292 -r 96660987de96 src/auth/mech-rpa.c --- a/src/auth/mech-rpa.c Wed May 07 20:24:05 2014 +0300 +++ b/src/auth/mech-rpa.c Wed May 07 23:22:13 2014 +0300 @@ -557,8 +557,7 @@ struct rpa_auth_request *request = (struct rpa_auth_request *)auth_request; - if (request->pwd_md5 != NULL) - safe_memset(request->pwd_md5, 0, sizeof(request->pwd_md5)); + safe_memset(request->pwd_md5, 0, sizeof(request->pwd_md5)); pool_unref(&auth_request->pool); } From dovecot at dovecot.org Wed May 7 20:26:45 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 20:26:45 +0000 Subject: dovecot-2.2: Fixed compiling on systems without MAP_ANONYMOUS Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b68e9f4e797f changeset: 17343:b68e9f4e797f user: Timo Sirainen date: Wed May 07 23:25:50 2014 +0300 description: Fixed compiling on systems without MAP_ANONYMOUS For example OSX. diffstat: src/lib/test-hash-method.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (28 lines): diff -r 96660987de96 -r b68e9f4e797f src/lib/test-hash-method.c --- a/src/lib/test-hash-method.c Wed May 07 23:22:13 2014 +0300 +++ b/src/lib/test-hash-method.c Wed May 07 23:25:50 2014 +0300 @@ -4,6 +4,10 @@ #include "mmap-util.h" #include "hash-method.h" +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +# define MAP_ANONYMOUS MAP_ANON +#endif + static unsigned char *buf; static unsigned int buf_size; @@ -33,9 +37,13 @@ unsigned int i; buf_size = mmap_get_page_size(); +#ifdef MAP_ANONYMOUS buf = mmap(NULL, buf_size*2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); mprotect(buf + buf_size, buf_size, PROT_NONE); +#else + buf = i_malloc(buf_size); +#endif memset(buf, 0, buf_size); for (i = 0; hash_methods[i] != NULL; i++) From dovecot at dovecot.org Wed May 7 20:27:30 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 20:27:30 +0000 Subject: dovecot-2.2: lib-mail: Added asserts to make static analyzer hap... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fc4a19b17fb3 changeset: 17344:fc4a19b17fb3 user: Timo Sirainen date: Wed May 07 23:26:57 2014 +0300 description: lib-mail: Added asserts to make static analyzer happier diffstat: src/lib-mail/message-parser.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (20 lines): diff -r b68e9f4e797f -r fc4a19b17fb3 src/lib-mail/message-parser.c --- a/src/lib-mail/message-parser.c Wed May 07 23:25:50 2014 +0300 +++ b/src/lib-mail/message-parser.c Wed May 07 23:26:57 2014 +0300 @@ -165,6 +165,8 @@ { struct message_part *p, *part, **list; + i_assert(parent != NULL); + part = p_new(pool, struct message_part, 1); part->parent = parent; for (p = parent; p != NULL; p = p->parent) @@ -310,6 +312,7 @@ message_size_add(&part->parent->body_size, &part->body_size); message_size_add(&part->parent->body_size, &part->header_size); } + i_assert(part != NULL); ctx->part = part; if (boundary->epilogue_found) { From dovecot at dovecot.org Wed May 7 20:33:01 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 May 2014 20:33:01 +0000 Subject: dovecot-2.2: dsync: Make static analyzer happier (hopefully) Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/24d27f7da7b2 changeset: 17345:24d27f7da7b2 user: Timo Sirainen date: Wed May 07 23:32:28 2014 +0300 description: dsync: Make static analyzer happier (hopefully) diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r fc4a19b17fb3 -r 24d27f7da7b2 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Wed May 07 23:26:57 2014 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Wed May 07 23:32:28 2014 +0300 @@ -327,6 +327,9 @@ struct istream *input1, *input2; int ret; + i_assert(attr1->value_stream != NULL || attr1->value != NULL); + i_assert(attr2->value_stream != NULL || attr2->value != NULL); + if (attr1->value != NULL && attr2->value != NULL) { *cmp_r = strcmp(attr1->value, attr2->value); return 0; From dovecot at dovecot.org Thu May 8 07:22:37 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 07:22:37 +0000 Subject: dovecot-2.2: run-test.sh: Valgrind version check was broken for ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f64ccd83673d changeset: 17346:f64ccd83673d user: Timo Sirainen date: Thu May 08 10:21:56 2014 +0300 description: run-test.sh: Valgrind version check was broken for v3.10+, removed it entirely. RHEL 5.9 has valgrind v3.5 already, so there shouldn't really be any important OSes using old valgrind that we need to support. diffstat: run-test.sh | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) diffs (21 lines): diff -r 24d27f7da7b2 -r f64ccd83673d run-test.sh --- a/run-test.sh Wed May 07 23:32:28 2014 +0300 +++ b/run-test.sh Thu May 08 10:21:56 2014 +0300 @@ -2,15 +2,8 @@ trap "rm -f test.out.$$" 0 1 2 3 15 -if valgrind --version | grep '^valgrind-3.[012]'; then - # RHEL 5.4 still has Valgrind v3.2 - valgrind -q --log-file-exactly=test.out.$$ $* - ret=$? -else - # v3.3+ - valgrind -q --log-file=test.out.$$ $* - ret=$? -fi +valgrind -q --log-file=test.out.$$ $* +ret=$? if [ -s test.out.$$ ]; then cat test.out.$$ exit 1 From dovecot at dovecot.org Thu May 8 08:30:12 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 08:30:12 +0000 Subject: dovecot-2.2: Fixed compiling when building without SSL support. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/10ce023ebf79 changeset: 17347:10ce023ebf79 user: Timo Sirainen date: Thu May 08 11:29:34 2014 +0300 description: Fixed compiling when building without SSL support. diffstat: src/login-common/ssl-proxy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r f64ccd83673d -r 10ce023ebf79 src/login-common/ssl-proxy.c --- a/src/login-common/ssl-proxy.c Thu May 08 10:21:56 2014 +0300 +++ b/src/login-common/ssl-proxy.c Thu May 08 11:29:34 2014 +0300 @@ -86,6 +86,8 @@ return ""; } +void ssl_proxy_destroy(struct ssl_proxy *proxy ATTR_UNUSED) {} + void ssl_proxy_free(struct ssl_proxy **proxy ATTR_UNUSED) {} unsigned int ssl_proxy_get_count(void) From dovecot at dovecot.org Thu May 8 09:39:52 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 09:39:52 +0000 Subject: dovecot-2.2: Make static analyzer happier Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c6c44f136100 changeset: 17348:c6c44f136100 user: Timo Sirainen date: Thu May 08 12:39:10 2014 +0300 description: Make static analyzer happier diffstat: src/lib-mail/test-message-part.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 10ce023ebf79 -r c6c44f136100 src/lib-mail/test-message-part.c --- a/src/lib-mail/test-message-part.c Thu May 08 11:29:34 2014 +0300 +++ b/src/lib-mail/test-message-part.c Thu May 08 12:39:10 2014 +0300 @@ -73,8 +73,9 @@ prev_part = part; part = message_part_by_idx(parts, i); test_assert(part != NULL); - test_assert(message_part_to_idx(part) == i); - test_assert(prev_part->physical_pos < part->physical_pos); + test_assert(part != NULL && message_part_to_idx(part) == i); + test_assert(part != NULL && + prev_part->physical_pos < part->physical_pos); } test_assert(message_part_by_idx(parts, i) == NULL); From dovecot at dovecot.org Thu May 8 10:28:17 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 10:28:17 +0000 Subject: dovecot-2.2: fts-tika: Removed lib-http kludgy workaround, which... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5054f75630c7 changeset: 17349:5054f75630c7 user: Timo Sirainen date: Thu May 08 13:27:43 2014 +0300 description: fts-tika: Removed lib-http kludgy workaround, which is no longer needed. diffstat: src/plugins/fts/fts-parser-tika.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (29 lines): diff -r c6c44f136100 -r 5054f75630c7 src/plugins/fts/fts-parser-tika.c --- a/src/plugins/fts/fts-parser-tika.c Thu May 08 12:39:10 2014 +0300 +++ b/src/plugins/fts/fts-parser-tika.c Thu May 08 13:27:43 2014 +0300 @@ -27,7 +27,6 @@ struct io *io; struct istream *payload; - bool http_req_finished; bool failed; }; @@ -104,7 +103,7 @@ parser->failed = TRUE; break; } - parser->http_req_finished = TRUE; + parser->http_req = NULL; io_loop_stop(current_ioloop); } @@ -205,7 +204,7 @@ i_stream_unref(&parser->payload); /* FIXME: kludgy, http_req should be NULL here if we don't want to free it. requires lib-http changes. */ - if (parser->http_req != NULL && !parser->http_req_finished) + if (parser->http_req != NULL) http_client_request_abort(&parser->http_req); i_free(parser); } From dovecot at dovecot.org Thu May 8 10:46:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 10:46:23 +0000 Subject: dovecot-2.2: lib-storage: Code cleanups and potential crashfix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b9d91c59bc5b changeset: 17350:b9d91c59bc5b user: Timo Sirainen date: Thu May 08 13:45:37 2014 +0300 description: lib-storage: Code cleanups and potential crashfix. Usually in blocks_count_lines() the full_input stream reading doesn't return eof=true in the last read but only on the next. If this had changed for some reason the code would have crashed in the assert checks. diffstat: src/lib-storage/index/index-mail-binary.c | 33 +++++++++++++++++++----------- 1 files changed, 21 insertions(+), 12 deletions(-) diffs (70 lines): diff -r 5054f75630c7 -r b9d91c59bc5b src/lib-storage/index/index-mail-binary.c --- a/src/lib-storage/index/index-mail-binary.c Thu May 08 13:27:43 2014 +0300 +++ b/src/lib-storage/index/index-mail-binary.c Thu May 08 13:45:37 2014 +0300 @@ -33,6 +33,9 @@ struct mail *mail; struct istream *input; bool has_nuls, converted; + /* each block is its own input stream. basically each converted MIME + body has its own block and the parts between the MIME bodies are + unconverted blocks */ ARRAY(struct binary_block) blocks; uoff_t copy_start_offset; @@ -306,23 +309,27 @@ { struct binary_block *blocks, *cur_block; unsigned int block_idx, block_count; - uoff_t cur_offset, cur_size; + uoff_t cur_block_offset, cur_block_size; const unsigned char *data, *p; size_t size, skip; ssize_t ret; blocks = array_get_modifiable(&ctx->blocks, &block_count); cur_block = blocks; - cur_offset = 0; + cur_block_offset = 0; block_idx = 0; + /* count the number of lines each block contains */ while ((ret = i_stream_read_data(full_input, &data, &size, 0)) > 0) { - i_assert(cur_offset <= cur_block->input->v_offset); + i_assert(cur_block_offset <= cur_block->input->v_offset); if (cur_block->input->eof) { - cur_size = cur_block->input->v_offset + + /* this is the last input for this block. the input + may also contain the next block's data, which we + don't want to include in this block's line count. */ + cur_block_size = cur_block->input->v_offset + i_stream_get_data_size(cur_block->input); - i_assert(size >= cur_size - cur_offset); - size = cur_size - cur_offset; + i_assert(size >= cur_block_size - cur_block_offset); + size = cur_block_size - cur_block_offset; } skip = size; while ((p = memchr(data, '\n', size)) != NULL) { @@ -331,14 +338,16 @@ cur_block->body_lines_count++; } i_stream_skip(full_input, skip); - cur_offset += skip; + cur_block_offset += skip; if (cur_block->input->eof) { - if (++block_idx == block_count) - cur_block = NULL; - else - cur_block++; - cur_offset = 0; + /* go to the next block */ + if (++block_idx == block_count) { + i_assert(i_stream_is_eof(full_input)); + break; + } + cur_block++; + cur_block_offset = 0; } } i_assert(ret == -1); From dovecot at dovecot.org Thu May 8 11:12:24 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:12:24 +0000 Subject: dovecot-2.2: treewide sparse cleanup - make single-unit-only dat... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7f6c5e27b908 changeset: 17351:7f6c5e27b908 user: Phil Carmody date: Tue May 06 18:10:55 2014 +0300 description: treewide sparse cleanup - make single-unit-only data static Helps keep the global namespace clean. Not all the things suggested by sparse have been moved. All DOVECOT_ABI_VERSION strings, and anything replicated in all-settings.c by src/config/settings-get.pl has been left untouched. Some of the latter could be moved, but the script would need to be modified to replicate the 'static' (it outputs 'extern'). diffstat: src/lib-index/mail-index-strmap.c | 2 +- src/lib-lda/mail-send.c | 2 -- src/lib-storage/mail-search-register-imap.c | 2 +- src/lib/child-wait.c | 2 +- src/lib/hash-method.c | 2 +- src/login-common/client-common.c | 3 ++- src/plugins/fts-lucene/doveadm-fts-lucene.c | 2 +- src/plugins/fts/doveadm-dump-fts-expunge-log.c | 2 +- src/plugins/fts/fts-parser-html.c | 2 +- src/plugins/fts/fts-parser.c | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-) diffs (121 lines): diff -r b9d91c59bc5b -r 7f6c5e27b908 src/lib-index/mail-index-strmap.c --- a/src/lib-index/mail-index-strmap.c Thu May 08 13:45:37 2014 +0300 +++ b/src/lib-index/mail-index-strmap.c Tue May 06 18:10:55 2014 +0300 @@ -89,7 +89,7 @@ #define MAIL_INDEX_STRMAP_TIMEOUT_SECS 10 -const struct dotlock_settings default_dotlock_settings = { +static const struct dotlock_settings default_dotlock_settings = { .timeout = MAIL_INDEX_STRMAP_TIMEOUT_SECS, .stale_timeout = 30 }; diff -r b9d91c59bc5b -r 7f6c5e27b908 src/lib-lda/mail-send.c --- a/src/lib-lda/mail-send.c Thu May 08 13:45:37 2014 +0300 +++ b/src/lib-lda/mail-send.c Tue May 06 18:10:55 2014 +0300 @@ -21,8 +21,6 @@ #include #include -int global_outgoing_count = 0; - static const struct var_expand_table * get_var_expand_table(struct mail *mail, const char *reason, const char *recipient) diff -r b9d91c59bc5b -r 7f6c5e27b908 src/lib-storage/mail-search-register-imap.c --- a/src/lib-storage/mail-search-register-imap.c Thu May 08 13:45:37 2014 +0300 +++ b/src/lib-storage/mail-search-register-imap.c Tue May 06 18:10:55 2014 +0300 @@ -501,7 +501,7 @@ return sarg; } -const struct mail_search_register_arg imap_register_args[] = { +static const struct mail_search_register_arg imap_register_args[] = { /* argument set operations */ { "NOT", imap_search_not }, { "OR", imap_search_or }, diff -r b9d91c59bc5b -r 7f6c5e27b908 src/lib/child-wait.c --- a/src/lib/child-wait.c Thu May 08 13:45:37 2014 +0300 +++ b/src/lib/child-wait.c Tue May 06 18:10:55 2014 +0300 @@ -15,7 +15,7 @@ }; /* pid_t => wait */ -HASH_TABLE(void *, struct child_wait *) child_pids; +static HASH_TABLE(void *, struct child_wait *) child_pids; #undef child_wait_new_with_pid struct child_wait * diff -r b9d91c59bc5b -r 7f6c5e27b908 src/lib/hash-method.c --- a/src/lib/hash-method.c Thu May 08 13:45:37 2014 +0300 +++ b/src/lib/hash-method.c Tue May 06 18:10:55 2014 +0300 @@ -47,7 +47,7 @@ result_r[7] = (*ctx & 0x00000000000000ffULL); } -const struct hash_method hash_method_size = { +static const struct hash_method hash_method_size = { "size", sizeof(uint64_t), sizeof(uint64_t), diff -r b9d91c59bc5b -r 7f6c5e27b908 src/login-common/client-common.c --- a/src/login-common/client-common.c Thu May 08 13:45:37 2014 +0300 +++ b/src/login-common/client-common.c Tue May 06 18:10:55 2014 +0300 @@ -25,7 +25,8 @@ #include -struct client *clients = NULL, *last_client = NULL; +struct client *clients = NULL; +static struct client *last_client = NULL; static unsigned int clients_count = 0; static void client_idle_disconnect_timeout(struct client *client) diff -r b9d91c59bc5b -r 7f6c5e27b908 src/plugins/fts-lucene/doveadm-fts-lucene.c --- a/src/plugins/fts-lucene/doveadm-fts-lucene.c Thu May 08 13:45:37 2014 +0300 +++ b/src/plugins/fts-lucene/doveadm-fts-lucene.c Tue May 06 18:10:55 2014 +0300 @@ -53,7 +53,7 @@ return stat(path, &st) == 0; } -struct doveadm_cmd_dump doveadm_cmd_dump_fts_lucene = { +static const struct doveadm_cmd_dump doveadm_cmd_dump_fts_lucene = { "fts-lucene", test_dump_fts_lucene, cmd_dump_fts_lucene diff -r b9d91c59bc5b -r 7f6c5e27b908 src/plugins/fts/doveadm-dump-fts-expunge-log.c --- a/src/plugins/fts/doveadm-dump-fts-expunge-log.c Thu May 08 13:45:37 2014 +0300 +++ b/src/plugins/fts/doveadm-dump-fts-expunge-log.c Tue May 06 18:10:55 2014 +0300 @@ -97,7 +97,7 @@ return strcmp(p, "dovecot-expunges.log") == 0; } -struct doveadm_cmd_dump doveadm_cmd_dump_fts_expunge_log = { +static const struct doveadm_cmd_dump doveadm_cmd_dump_fts_expunge_log = { "fts-expunge-log", test_dump_fts_expunge_log, cmd_dump_fts_expunge_log diff -r b9d91c59bc5b -r 7f6c5e27b908 src/plugins/fts/fts-parser-html.c --- a/src/plugins/fts/fts-parser-html.c Thu May 08 13:45:37 2014 +0300 +++ b/src/plugins/fts/fts-parser-html.c Tue May 06 18:10:55 2014 +0300 @@ -36,7 +36,7 @@ bool ignore_next_text; }; -struct { +static struct { const char *name; unichar_t chr; } html_entities[] = { diff -r b9d91c59bc5b -r 7f6c5e27b908 src/plugins/fts/fts-parser.c --- a/src/plugins/fts/fts-parser.c Thu May 08 13:45:37 2014 +0300 +++ b/src/plugins/fts/fts-parser.c Tue May 06 18:10:55 2014 +0300 @@ -6,7 +6,7 @@ #include "message-parser.h" #include "fts-parser.h" -const struct fts_parser_vfuncs *parsers[] = { +static const struct fts_parser_vfuncs *parsers[] = { &fts_parser_html, &fts_parser_script, &fts_parser_tika From dovecot at dovecot.org Thu May 8 11:12:24 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:12:24 +0000 Subject: dovecot-2.2: lib-storage: Make struct fail_storage/mailbox/mail_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d7a66090b7c7 changeset: 17352:d7a66090b7c7 user: Timo Sirainen date: Thu May 08 14:11:46 2014 +0300 description: lib-storage: Make struct fail_storage/mailbox/mail_vfuncs properly extern. These could be useful when implementing some new dummy storage backends. diffstat: src/lib-storage/fail-mail-storage.c | 2 -- src/lib-storage/fail-mail-storage.h | 4 ++++ src/lib-storage/fail-mail.c | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diffs (38 lines): diff -r 7f6c5e27b908 -r d7a66090b7c7 src/lib-storage/fail-mail-storage.c --- a/src/lib-storage/fail-mail-storage.c Tue May 06 18:10:55 2014 +0300 +++ b/src/lib-storage/fail-mail-storage.c Thu May 08 14:11:46 2014 +0300 @@ -5,8 +5,6 @@ #include "mail-storage-private.h" #include "fail-mail-storage.h" -extern struct mail_storage fail_storage; - static struct mail_storage *fail_storage_alloc(void) { struct mail_storage *storage; diff -r 7f6c5e27b908 -r d7a66090b7c7 src/lib-storage/fail-mail-storage.h --- a/src/lib-storage/fail-mail-storage.h Tue May 06 18:10:55 2014 +0300 +++ b/src/lib-storage/fail-mail-storage.h Thu May 08 14:11:46 2014 +0300 @@ -1,6 +1,10 @@ #ifndef FAIL_MAIL_STORAGE_H #define FAIL_MAIL_STORAGE_H +extern struct mail_storage fail_storage; +extern struct mailbox fail_mailbox; +extern struct mail_vfuncs fail_mail_vfuncs; + struct mail_storage *fail_mail_storage_create(void); struct mailbox * diff -r 7f6c5e27b908 -r d7a66090b7c7 src/lib-storage/fail-mail.c --- a/src/lib-storage/fail-mail.c Tue May 06 18:10:55 2014 +0300 +++ b/src/lib-storage/fail-mail.c Thu May 08 14:11:46 2014 +0300 @@ -5,8 +5,6 @@ #include "mail-storage-private.h" #include "fail-mail-storage.h" -extern struct mail_vfuncs fail_mail_vfuncs; - struct mail * fail_mailbox_mail_alloc(struct mailbox_transaction_context *t, enum mail_fetch_field wanted_fields ATTR_UNUSED, From dovecot at dovecot.org Thu May 8 11:16:01 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:16:01 +0000 Subject: dovecot-2.2: lib: a couple of trivial sparse cleanups Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3d7b9a927656 changeset: 17353:3d7b9a927656 user: Phil Carmody date: Wed May 07 16:52:22 2014 +0300 description: lib: a couple of trivial sparse cleanups The #include isn't needed on modern linux, as the macros are already defined The compiler seems to silently ignore redefinitions in system header files, so didn't throw a warning, but probably should have, as redefinitions can lead to insanity. The cast just makes it explicit that we're changing the prototype. diffstat: src/lib/file-set-size.c | 3 ++- src/lib/istream.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diffs (25 lines): diff -r d7a66090b7c7 -r 3d7b9a927656 src/lib/file-set-size.c --- a/src/lib/file-set-size.c Thu May 08 14:11:46 2014 +0300 +++ b/src/lib/file-set-size.c Wed May 07 16:52:22 2014 +0300 @@ -14,7 +14,8 @@ #include #include #include -#ifdef HAVE_LINUX_FALLOC_H +#if defined(HAVE_LINUX_FALLOC_H) && !defined(FALLOC_FL_KEEP_SIZE) +/* Legacy Linux does not have the FALLOC_FL_* flags under fcntl.h */ # include #endif diff -r d7a66090b7c7 -r 3d7b9a927656 src/lib/istream.c --- a/src/lib/istream.c Thu May 08 14:11:46 2014 +0300 +++ b/src/lib/istream.c Wed May 07 16:52:22 2014 +0300 @@ -77,7 +77,7 @@ dcs = array_get(&iostream->destroy_callbacks, &count); for (i = 0; i < count; i++) { - if (dcs[i].callback == callback) { + if (dcs[i].callback == (istream_callback_t *)callback) { array_delete(&iostream->destroy_callbacks, i, 1); return; } From dovecot at dovecot.org Thu May 8 11:16:01 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:16:01 +0000 Subject: dovecot-2.2: lib: wildcard-match - use NULL not 0 for pointers Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c31bd0065d91 changeset: 17354:c31bd0065d91 user: Phil Carmody date: Thu May 08 11:20:36 2014 +0300 description: lib: wildcard-match - use NULL not 0 for pointers Flagged by sparse. diffstat: src/lib/wildcard-match.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (36 lines): diff -r 3d7b9a927656 -r c31bd0065d91 src/lib/wildcard-match.c --- a/src/lib/wildcard-match.c Wed May 07 16:52:22 2014 +0300 +++ b/src/lib/wildcard-match.c Thu May 08 11:20:36 2014 +0300 @@ -25,12 +25,12 @@ static int wildcard_match_int(const char *data, const char *mask, int icase) { - const char *ma = mask, *na = data, *lsm = 0, *lsn = 0; + const char *ma = mask, *na = data, *lsm = NULL, *lsn = NULL; int match = 1; int sofar = 0; /* null strings should never match */ - if ((ma == 0) || (na == 0) || (!*ma) || (!*na)) + if ((ma == NULL) || (na == NULL) || (!*ma) || (!*na)) return NOMATCH; /* find the end of each string */ while (*(++mask)); @@ -46,7 +46,7 @@ data = --lsn; mask = lsm; if (data < na) - lsm = 0; + lsm = NULL; sofar = 0; } else @@ -81,7 +81,7 @@ data = --lsn; mask = lsm; if (data < na) - lsm = 0; /* Rewind to saved pos */ + lsm = NULL; /* Rewind to saved pos */ sofar = 0; continue; /* Next char, please */ } From dovecot at dovecot.org Thu May 8 11:26:10 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:26:10 +0000 Subject: dovecot-2.2: lib: cosmetic - rename parameters so that .h and .c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/de99b926a9ad changeset: 17355:de99b926a9ad user: Phil Carmody date: Tue May 06 12:44:38 2014 +0300 description: lib: cosmetic - rename parameters so that .h and .c files match These functions were flagging sparse warnings, but those warnings are trivially (robotically) dismissable if the parameters are identically named in the two contexts. Opted for whichever name seemed to be more meaningful or sensible. e.g. char** became p rather than s, as it's a pointer more than a string. diffstat: src/lib/strfuncs.c | 8 ++++---- src/lib/strfuncs.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diffs (39 lines): diff -r c31bd0065d91 -r de99b926a9ad src/lib/strfuncs.c --- a/src/lib/strfuncs.c Thu May 08 11:20:36 2014 +0300 +++ b/src/lib/strfuncs.c Tue May 06 12:44:38 2014 +0300 @@ -366,9 +366,9 @@ return strcmp(key, *member); } -int i_strcmp_p(const char *const *s1, const char *const *s2) +int i_strcmp_p(const char *const *p1, const char *const *p2) { - return strcmp(*s1, *s2); + return strcmp(*p1, *p2); } int bsearch_strcasecmp(const char *key, const char *const *member) @@ -376,9 +376,9 @@ return strcasecmp(key, *member); } -int i_strcasecmp_p(const char *const *s1, const char *const *s2) +int i_strcasecmp_p(const char *const *p1, const char *const *p2) { - return strcasecmp(*s1, *s2); + return strcasecmp(*p1, *p2); } static char ** diff -r c31bd0065d91 -r de99b926a9ad src/lib/strfuncs.h --- a/src/lib/strfuncs.h Thu May 08 11:20:36 2014 +0300 +++ b/src/lib/strfuncs.h Tue May 06 12:44:38 2014 +0300 @@ -50,7 +50,7 @@ const char *t_str_ucase(const char *str); int null_strcmp(const char *s1, const char *s2) ATTR_PURE; -int bsearch_strcmp(const char *p1, const char *const *member) ATTR_PURE; +int bsearch_strcmp(const char *key, const char *const *member) ATTR_PURE; int bsearch_strcasecmp(const char *key, const char *const *member) ATTR_PURE; int i_memcasecmp(const void *p1, const void *p2, size_t size) ATTR_PURE; int i_strcmp_p(const char *const *p1, const char *const *p2) ATTR_PURE; From dovecot at dovecot.org Thu May 8 11:35:21 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:35:21 +0000 Subject: dovecot-2.2: lib: fd_read() didn't check the msg.msg_controllen ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bedecd5b6bab changeset: 17356:bedecd5b6bab user: Timo Sirainen date: Thu May 08 14:34:39 2014 +0300 description: lib: fd_read() didn't check the msg.msg_controllen size correctly diffstat: src/lib/fdpass.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r de99b926a9ad -r bedecd5b6bab src/lib/fdpass.c --- a/src/lib/fdpass.c Tue May 06 12:44:38 2014 +0300 +++ b/src/lib/fdpass.c Thu May 08 14:34:39 2014 +0300 @@ -143,7 +143,7 @@ #ifdef __osf__ # define CHECK_MSG(msg) TRUE /* Tru64 */ #else -# define CHECK_MSG(msg) (msg).msg_controllen >= CMSG_SPACE(sizeof(int)) +# define CHECK_MSG(msg) ((msg).msg_controllen >= CMSG_SPACE(sizeof(int))) #endif #ifdef LINUX20 From dovecot at dovecot.org Thu May 8 11:58:43 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 11:58:43 +0000 Subject: dovecot-2.2: run-tests.sh: Add support for reading valgrind supp... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/802187be0f77 changeset: 17357:802187be0f77 user: Teemu Huovila date: Thu May 08 14:57:56 2014 +0300 description: run-tests.sh: Add support for reading valgrind suppressions if they exist. diffstat: run-test.sh | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (18 lines): diff -r bedecd5b6bab -r 802187be0f77 run-test.sh --- a/run-test.sh Thu May 08 14:34:39 2014 +0300 +++ b/run-test.sh Thu May 08 14:57:56 2014 +0300 @@ -1,8 +1,12 @@ #!/bin/sh trap "rm -f test.out.$$" 0 1 2 3 15 - -valgrind -q --log-file=test.out.$$ $* +supp_path="`dirname $0`/run-test-valgrind.supp" +if [ -r "$supp_path" ]; then + valgrind -q --suppressions="$supp_path" --log-file=test.out.$$ $* +else + valgrind -q --log-file=test.out.$$ $* +fi ret=$? if [ -s test.out.$$ ]; then cat test.out.$$ From dovecot at dovecot.org Thu May 8 12:12:04 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 12:12:04 +0000 Subject: dovecot-2.2: Removed unnecessary #includes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f101636138fa changeset: 17358:f101636138fa user: Teemu Huovila date: Thu May 08 15:11:26 2014 +0300 description: Removed unnecessary #includes. diffstat: src/lda/main.c | 1 - src/lib-lda/smtp-client.h | 2 -- 2 files changed, 0 insertions(+), 3 deletions(-) diffs (23 lines): diff -r 802187be0f77 -r f101636138fa src/lda/main.c --- a/src/lda/main.c Thu May 08 14:57:56 2014 +0300 +++ b/src/lda/main.c Thu May 08 15:11:26 2014 +0300 @@ -10,7 +10,6 @@ #include "safe-mkstemp.h" #include "eacces-error.h" #include "ipwd.h" -#include "mkdir-parents.h" #include "str.h" #include "str-sanitize.h" #include "strescape.h" diff -r 802187be0f77 -r f101636138fa src/lib-lda/smtp-client.h --- a/src/lib-lda/smtp-client.h Thu May 08 14:57:56 2014 +0300 +++ b/src/lib-lda/smtp-client.h Thu May 08 15:11:26 2014 +0300 @@ -1,8 +1,6 @@ #ifndef SMTP_CLIENT_H #define SMTP_CLIENT_H -#include - struct smtp_client * ATTR_NULL(3) smtp_client_init(const struct lda_settings *set, const char *return_path); /* Add a new recipient */ From dovecot at dovecot.org Thu May 8 13:18:33 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 13:18:33 +0000 Subject: dovecot-2.1: Fixed compiling when building without SSL support. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5162c2051642 changeset: 15016:5162c2051642 user: Timo Sirainen date: Thu May 08 11:29:34 2014 +0300 description: Fixed compiling when building without SSL support. diffstat: src/login-common/ssl-proxy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r b7ac23b4d339 -r 5162c2051642 src/login-common/ssl-proxy.c --- a/src/login-common/ssl-proxy.c Wed May 07 17:26:21 2014 +0300 +++ b/src/login-common/ssl-proxy.c Thu May 08 11:29:34 2014 +0300 @@ -84,6 +84,8 @@ return ""; } +void ssl_proxy_destroy(struct ssl_proxy *proxy ATTR_UNUSED) {} + void ssl_proxy_free(struct ssl_proxy **proxy ATTR_UNUSED) {} unsigned int ssl_proxy_get_count(void) From dovecot at dovecot.org Thu May 8 13:21:11 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 13:21:11 +0000 Subject: dovecot-2.0: *-login: SSL connections didn't get closed when the... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/48f90e7e92dc changeset: 13109:48f90e7e92dc user: Timo Sirainen date: Thu May 08 16:20:36 2014 +0300 description: *-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/login-common/client-common.c | 2 ++ src/login-common/ssl-proxy-openssl.c | 3 +-- src/login-common/ssl-proxy.c | 2 ++ src/login-common/ssl-proxy.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diffs (55 lines): diff -r 74d9f61e224d -r 48f90e7e92dc src/login-common/client-common.c --- a/src/login-common/client-common.c Tue Nov 27 08:44:12 2012 +0200 +++ b/src/login-common/client-common.c Thu May 08 16:20:36 2014 +0300 @@ -105,6 +105,8 @@ last_client = client->prev; DLLIST_REMOVE(&clients, client); + if (!client->login_success && client->ssl_proxy != NULL) + ssl_proxy_destroy(client->ssl_proxy); if (client->input != NULL) i_stream_close(client->input); if (client->output != NULL) diff -r 74d9f61e224d -r 48f90e7e92dc src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Tue Nov 27 08:44:12 2012 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Thu May 08 16:20:36 2014 +0300 @@ -103,7 +103,6 @@ static void ssl_read(struct ssl_proxy *proxy); static void ssl_write(struct ssl_proxy *proxy); static void ssl_step(struct ssl_proxy *proxy); -static void ssl_proxy_destroy(struct ssl_proxy *proxy); static void ssl_proxy_unref(struct ssl_proxy *proxy); static struct ssl_server_context * @@ -845,7 +844,7 @@ i_free(proxy); } -static void ssl_proxy_destroy(struct ssl_proxy *proxy) +void ssl_proxy_destroy(struct ssl_proxy *proxy) { if (proxy->destroyed) return; diff -r 74d9f61e224d -r 48f90e7e92dc src/login-common/ssl-proxy.c --- a/src/login-common/ssl-proxy.c Tue Nov 27 08:44:12 2012 +0200 +++ b/src/login-common/ssl-proxy.c Thu May 08 16:20:36 2014 +0300 @@ -77,6 +77,8 @@ return NULL; } +void ssl_proxy_destroy(struct ssl_proxy *proxy ATTR_UNUSED) {} + void ssl_proxy_free(struct ssl_proxy **proxy ATTR_UNUSED) {} unsigned int ssl_proxy_get_count(void) diff -r 74d9f61e224d -r 48f90e7e92dc src/login-common/ssl-proxy.h --- a/src/login-common/ssl-proxy.h Tue Nov 27 08:44:12 2012 +0200 +++ b/src/login-common/ssl-proxy.h Thu May 08 16:20:36 2014 +0300 @@ -30,6 +30,7 @@ const char *ssl_proxy_get_last_error(const struct ssl_proxy *proxy) ATTR_PURE; const char *ssl_proxy_get_security_string(struct ssl_proxy *proxy); const char *ssl_proxy_get_compression(struct ssl_proxy *proxy); +void ssl_proxy_destroy(struct ssl_proxy *proxy); void ssl_proxy_free(struct ssl_proxy **proxy); /* Return number of active SSL proxies */ From dovecot at dovecot.org Thu May 8 13:42:19 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 13:42:19 +0000 Subject: dovecot-1.2: *-login: SSL connections didn't get closed when the... Message-ID: details: http://hg.dovecot.org/dovecot-1.2/rev/8ba4253adc9b changeset: 9658:8ba4253adc9b user: Timo Sirainen date: Thu May 08 16:41:29 2014 +0300 description: *-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/imap-login/client.c | 2 ++ src/login-common/ssl-proxy-openssl.c | 3 +-- src/login-common/ssl-proxy.c | 2 ++ src/login-common/ssl-proxy.h | 1 + src/pop3-login/client.c | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diffs (67 lines): diff -r d6bd9acd97e7 -r 8ba4253adc9b src/imap-login/client.c --- a/src/imap-login/client.c Fri Oct 05 00:26:19 2012 +0300 +++ b/src/imap-login/client.c Thu May 08 16:41:29 2014 +0300 @@ -557,6 +557,8 @@ client_unlink(&client->common); + if (!client->login_success && client->common.proxy != NULL) + ssl_proxy_destroy(client->common.proxy); if (client->common.input != NULL) i_stream_close(client->common.input); if (client->output != NULL) diff -r d6bd9acd97e7 -r 8ba4253adc9b src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Fri Oct 05 00:26:19 2012 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Thu May 08 16:41:29 2014 +0300 @@ -80,7 +80,6 @@ static void ssl_read(struct ssl_proxy *proxy); static void ssl_write(struct ssl_proxy *proxy); static void ssl_step(struct ssl_proxy *proxy); -static void ssl_proxy_destroy(struct ssl_proxy *proxy); static void ssl_proxy_unref(struct ssl_proxy *proxy); static void ssl_params_corrupted(const char *path) @@ -676,7 +675,7 @@ main_unref(); } -static void ssl_proxy_destroy(struct ssl_proxy *proxy) +void ssl_proxy_destroy(struct ssl_proxy *proxy) { if (proxy->destroyed) return; diff -r d6bd9acd97e7 -r 8ba4253adc9b src/login-common/ssl-proxy.c --- a/src/login-common/ssl-proxy.c Fri Oct 05 00:26:19 2012 +0300 +++ b/src/login-common/ssl-proxy.c Thu May 08 16:41:29 2014 +0300 @@ -55,6 +55,8 @@ return ""; } +void ssl_proxy_destroy(struct ssl_proxy *proxy ATTR_UNUSED) {} + void ssl_proxy_free(struct ssl_proxy *proxy ATTR_UNUSED) {} unsigned int ssl_proxy_get_count(void) diff -r d6bd9acd97e7 -r 8ba4253adc9b src/login-common/ssl-proxy.h --- a/src/login-common/ssl-proxy.h Fri Oct 05 00:26:19 2012 +0300 +++ b/src/login-common/ssl-proxy.h Thu May 08 16:41:29 2014 +0300 @@ -24,6 +24,7 @@ bool ssl_proxy_is_handshaked(const struct ssl_proxy *proxy) ATTR_PURE; const char *ssl_proxy_get_last_error(const struct ssl_proxy *proxy) ATTR_PURE; const char *ssl_proxy_get_security_string(struct ssl_proxy *proxy); +void ssl_proxy_destroy(struct ssl_proxy *proxy); void ssl_proxy_free(struct ssl_proxy *proxy); /* Return number of active SSL proxies */ diff -r d6bd9acd97e7 -r 8ba4253adc9b src/pop3-login/client.c --- a/src/pop3-login/client.c Fri Oct 05 00:26:19 2012 +0300 +++ b/src/pop3-login/client.c Thu May 08 16:41:29 2014 +0300 @@ -359,6 +359,8 @@ client_unlink(&client->common); + if (!client->login_success && client->common.proxy != NULL) + ssl_proxy_destroy(client->common.proxy); if (client->common.input != NULL) i_stream_close(client->common.input); if (client->output != NULL) From dovecot at dovecot.org Thu May 8 14:03:10 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:03:10 +0000 Subject: dovecot-2.2: lib-storage: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9e3e46409415 changeset: 17359:9e3e46409415 user: Timo Sirainen date: Thu May 08 17:02:19 2014 +0300 description: lib-storage: Removed unnecessary code. mailbox_dir_name is never NULL, and when it's empty it can be handled exactly the same as when it's non-empty. diffstat: src/lib-storage/list/mailbox-list-index-backend.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diffs (21 lines): diff -r f101636138fa -r 9e3e46409415 src/lib-storage/list/mailbox-list-index-backend.c --- a/src/lib-storage/list/mailbox-list-index-backend.c Thu May 08 15:11:26 2014 +0300 +++ b/src/lib-storage/list/mailbox-list-index-backend.c Thu May 08 17:02:19 2014 +0300 @@ -85,14 +85,9 @@ index_get_guid_path(struct mailbox_list *_list, const char *root_dir, const guid_128_t mailbox_guid) { - if (_list->set.mailbox_dir_name == '\0') { - return t_strconcat(root_dir, "/", - guid_128_to_string(mailbox_guid), NULL); - } else { - return t_strdup_printf("%s/%s%s", root_dir, - _list->set.mailbox_dir_name, - guid_128_to_string(mailbox_guid)); - } + return t_strdup_printf("%s/%s%s", root_dir, + _list->set.mailbox_dir_name, + guid_128_to_string(mailbox_guid)); } static int From dovecot at dovecot.org Thu May 8 14:04:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:04:53 +0000 Subject: dovecot-2.2: lib-storage: pop3c - fix invalid blank password check Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1b5c6a492e3a changeset: 17360:1b5c6a492e3a user: Phil Carmody date: Thu May 08 15:56:25 2014 +0300 description: lib-storage: pop3c - fix invalid blank password check The pointer will never be NULL, as it's initialised pointing to an empty string, and can only be overridden by setting it to another string. So the test always failed. Instead, check the 1st character of the password. diffstat: src/lib-storage/index/pop3c/pop3c-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9e3e46409415 -r 1b5c6a492e3a src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Thu May 08 17:02:19 2014 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Thu May 08 15:56:25 2014 +0300 @@ -41,7 +41,7 @@ *error_r = "missing pop3c_host"; return -1; } - if (storage->set->pop3c_password == '\0') { + if (storage->set->pop3c_password[0] == '\0') { *error_r = "missing pop3c_password"; return -1; } From dovecot at dovecot.org Thu May 8 14:04:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:04:53 +0000 Subject: dovecot-2.2: lib-storage: maildir - don't use a bool to store a ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cb5b2a1579af changeset: 17361:cb5b2a1579af user: Phil Carmody date: Thu May 08 17:01:26 2014 +0300 description: lib-storage: maildir - don't use a bool to store a char diffstat: src/lib-storage/index/maildir/maildir-mail.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 1b5c6a492e3a -r cb5b2a1579af src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Thu May 08 15:56:25 2014 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Thu May 08 17:01:26 2014 +0300 @@ -653,7 +653,7 @@ struct maildir_size_fix_ctx { uoff_t physical_size; - bool wrong_key; + char wrong_key; }; static int From dovecot at dovecot.org Thu May 8 14:04:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:04:53 +0000 Subject: dovecot-2.2: treewide - use of explicit NULL in pointer comparis... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/36c2611e053e changeset: 17362:36c2611e053e user: Phil Carmody date: Thu May 08 15:53:27 2014 +0300 description: treewide - use of explicit NULL in pointer comparisons rather than 0-alikes Found by sparse. diffstat: src/doveadm/dsync/dsync-mailbox-tree.c | 6 +++--- src/lib-imap/imap-url.c | 2 +- src/lib-index/mail-cache-fields.c | 4 ++-- src/lib-storage/index/maildir/maildir-keywords.c | 4 ++-- src/lib-storage/index/maildir/maildir-save.c | 3 ++- src/lib-storage/mail-search-build.c | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diffs (108 lines): diff -r cb5b2a1579af -r 36c2611e053e src/doveadm/dsync/dsync-mailbox-tree.c --- a/src/doveadm/dsync/dsync-mailbox-tree.c Thu May 08 17:01:26 2014 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree.c Thu May 08 15:53:27 2014 +0300 @@ -67,7 +67,7 @@ const char *const *path; path = t_strsplit(full_name, tree->sep_str); - for (; *path != '\0' && node != NULL; path++) + for (; *path != NULL && node != NULL; path++) node = dsync_mailbox_node_find(node->first_child, *path); } T_END; return node; @@ -106,14 +106,14 @@ /* find the existing part */ path = t_strsplit(full_name, tree->sep_str); - for (; *path != '\0'; path++) { + for (; *path != NULL; path++) { parent = node; node = dsync_mailbox_node_find(node->first_child, *path); if (node == NULL) break; } /* create the rest */ - for (; *path != '\0'; path++) { + for (; *path != NULL; path++) { node = p_new(tree->pool, struct dsync_mailbox_node, 1); node->name = p_strdup(tree->pool, *path); node->ns = parent->ns; diff -r cb5b2a1579af -r 36c2611e053e src/lib-imap/imap-url.c --- a/src/lib-imap/imap-url.c Thu May 08 17:01:26 2014 +0300 +++ b/src/lib-imap/imap-url.c Thu May 08 15:53:27 2014 +0300 @@ -503,7 +503,7 @@ segment = path; /* Resolve relative URI path; determine what to copy from the base URI */ - if (url != NULL && url_parser->base != 0 && relative > 0) { + if (url != NULL && url_parser->base != NULL && relative > 0) { struct imap_url *base = url_parser->base; int rel = relative; diff -r cb5b2a1579af -r 36c2611e053e src/lib-index/mail-cache-fields.c --- a/src/lib-index/mail-cache-fields.c Thu May 08 17:01:26 2014 +0300 +++ b/src/lib-index/mail-cache-fields.c Thu May 08 15:53:27 2014 +0300 @@ -490,7 +490,7 @@ int ret = 0; if (mail_cache_header_fields_read(cache) < 0 || - mail_cache_header_fields_get_offset(cache, &offset, FALSE) < 0) + mail_cache_header_fields_get_offset(cache, &offset, NULL) < 0) return -1; buffer = buffer_create_dynamic(pool_datastack_create(), 256); @@ -596,7 +596,7 @@ int mail_cache_header_fields_get_next_offset(struct mail_cache *cache, uint32_t *offset_r) { - if (mail_cache_header_fields_get_offset(cache, offset_r, FALSE) < 0) + if (mail_cache_header_fields_get_offset(cache, offset_r, NULL) < 0) return -1; if (*offset_r == 0) { diff -r cb5b2a1579af -r 36c2611e053e src/lib-storage/index/maildir/maildir-keywords.c --- a/src/lib-storage/index/maildir/maildir-keywords.c Thu May 08 17:01:26 2014 +0300 +++ b/src/lib-storage/index/maildir/maildir-keywords.c Thu May 08 15:53:27 2014 +0300 @@ -200,7 +200,7 @@ void *value; value = hash_table_lookup(mk->hash, name); - if (value == 0) { + if (value == NULL) { if (mk->synced) return 0; @@ -209,7 +209,7 @@ i_assert(mk->synced); value = hash_table_lookup(mk->hash, name); - if (value == 0) + if (value == NULL) return 0; } diff -r cb5b2a1579af -r 36c2611e053e src/lib-storage/index/maildir/maildir-save.c --- a/src/lib-storage/index/maildir/maildir-save.c Thu May 08 17:01:26 2014 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Thu May 08 15:53:27 2014 +0300 @@ -897,7 +897,8 @@ array_append(&files, &mf, 1); array_sort(&files, maildir_filename_dest_basename_cmp); - new_changed = cur_changed = FALSE; prev_mf = FALSE; + new_changed = cur_changed = FALSE; + prev_mf = NULL; array_foreach(&files, mfp) { mf = *mfp; T_BEGIN { diff -r cb5b2a1579af -r 36c2611e053e src/lib-storage/mail-search-build.c --- a/src/lib-storage/mail-search-build.c Thu May 08 17:01:26 2014 +0300 +++ b/src/lib-storage/mail-search-build.c Thu May 08 15:53:27 2014 +0300 @@ -230,7 +230,7 @@ string_t *utf8 = t_str_new(128); enum charset_result result; - if (charset_to_utf8_str(ctx->charset, 0, + if (charset_to_utf8_str(ctx->charset, NULL, input, utf8, &result) < 0) { /* unknown charset */ ctx->_error = "Unknown charset"; From dovecot at dovecot.org Thu May 8 14:06:30 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:06:30 +0000 Subject: dovecot-1.1: *-login: SSL connections didn't get closed when the... Message-ID: details: http://hg.dovecot.org/dovecot-1.1/rev/fe0e6550585c changeset: 8378:fe0e6550585c user: Timo Sirainen date: Thu May 08 16:52:29 2014 +0300 description: *-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/imap-login/client.c | 2 ++ src/login-common/ssl-proxy-openssl.c | 3 +-- src/login-common/ssl-proxy.c | 2 ++ src/login-common/ssl-proxy.h | 1 + src/pop3-login/client.c | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diffs (67 lines): diff -r 0ce9c27b109b -r fe0e6550585c src/imap-login/client.c --- a/src/imap-login/client.c Wed Jun 20 02:21:54 2012 +0300 +++ b/src/imap-login/client.c Thu May 08 16:52:29 2014 +0300 @@ -489,6 +489,8 @@ client_unlink(&client->common); + if (!client->login_success && client->common.proxy != NULL) + ssl_proxy_destroy(client->common.proxy); if (client->input != NULL) i_stream_close(client->input); if (client->output != NULL) diff -r 0ce9c27b109b -r fe0e6550585c src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed Jun 20 02:21:54 2012 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Thu May 08 16:52:29 2014 +0300 @@ -75,7 +75,6 @@ static void ssl_read(struct ssl_proxy *proxy); static void ssl_write(struct ssl_proxy *proxy); static void ssl_step(struct ssl_proxy *proxy); -static void ssl_proxy_destroy(struct ssl_proxy *proxy); static void ssl_proxy_unref(struct ssl_proxy *proxy); static void ssl_params_corrupted(const char *path) @@ -616,7 +615,7 @@ main_unref(); } -static void ssl_proxy_destroy(struct ssl_proxy *proxy) +void ssl_proxy_destroy(struct ssl_proxy *proxy) { if (proxy->destroyed) return; diff -r 0ce9c27b109b -r fe0e6550585c src/login-common/ssl-proxy.c --- a/src/login-common/ssl-proxy.c Wed Jun 20 02:21:54 2012 +0300 +++ b/src/login-common/ssl-proxy.c Thu May 08 16:52:29 2014 +0300 @@ -46,6 +46,8 @@ return ""; } +void ssl_proxy_destroy(struct ssl_proxy *proxy ATTR_UNUSED) {} + void ssl_proxy_free(struct ssl_proxy *proxy ATTR_UNUSED) {} unsigned int ssl_proxy_get_count(void) diff -r 0ce9c27b109b -r fe0e6550585c src/login-common/ssl-proxy.h --- a/src/login-common/ssl-proxy.h Wed Jun 20 02:21:54 2012 +0300 +++ b/src/login-common/ssl-proxy.h Thu May 08 16:52:29 2014 +0300 @@ -16,6 +16,7 @@ bool ssl_proxy_is_handshaked(struct ssl_proxy *proxy); const char *ssl_proxy_get_last_error(struct ssl_proxy *proxy); const char *ssl_proxy_get_security_string(struct ssl_proxy *proxy); +void ssl_proxy_destroy(struct ssl_proxy *proxy); void ssl_proxy_free(struct ssl_proxy *proxy); /* Return number of active SSL proxies */ diff -r 0ce9c27b109b -r fe0e6550585c src/pop3-login/client.c --- a/src/pop3-login/client.c Wed Jun 20 02:21:54 2012 +0300 +++ b/src/pop3-login/client.c Thu May 08 16:52:29 2014 +0300 @@ -359,6 +359,8 @@ client_unlink(&client->common); + if (!client->login_success && client->common.proxy != NULL) + ssl_proxy_destroy(client->common.proxy); if (client->input != NULL) i_stream_close(client->input); if (client->output != NULL) From dovecot at dovecot.org Thu May 8 14:56:18 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 14:56:18 +0000 Subject: dovecot-2.1: director: Fixed handling weak users when there were... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/89c0689ab00b changeset: 15017:89c0689ab00b user: Timo Sirainen date: Wed Apr 23 23:26:49 2014 +0300 description: director: Fixed handling weak users when there were exactly 2 director servers in the ring. diffstat: src/director/director-connection.c | 2 +- src/director/director-request.c | 2 +- src/director/director.c | 26 +++++++++++++++++++++++--- src/director/director.h | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diffs (82 lines): diff -r 5162c2051642 -r 89c0689ab00b src/director/director-connection.c --- a/src/director/director-connection.c Thu May 08 11:29:34 2014 +0300 +++ b/src/director/director-connection.c Wed Apr 23 23:26:49 2014 +0300 @@ -798,7 +798,7 @@ if (!user->weak) director_update_user(conn->dir, src_host, user); else { - director_update_user_weak(conn->dir, src_host, + director_update_user_weak(conn->dir, src_host, conn, dir_host, user); } } diff -r 5162c2051642 -r 89c0689ab00b src/director/director-request.c --- a/src/director/director-request.c Thu May 08 11:29:34 2014 +0300 +++ b/src/director/director-request.c Wed Apr 23 23:26:49 2014 +0300 @@ -241,7 +241,7 @@ return TRUE; } else { user->weak = TRUE; - director_update_user_weak(dir, dir->self_host, NULL, user); + director_update_user_weak(dir, dir->self_host, NULL, NULL, user); request->delay_reason = REQUEST_DELAY_WEAK; dir_debug("request: %u set to weak", request->username_hash); return FALSE; diff -r 5162c2051642 -r 89c0689ab00b src/director/director.c --- a/src/director/director.c Thu May 08 11:29:34 2014 +0300 +++ b/src/director/director.c Wed Apr 23 23:26:49 2014 +0300 @@ -566,9 +566,12 @@ } void director_update_user_weak(struct director *dir, struct director_host *src, + struct director_connection *src_conn, struct director_host *orig_src, struct user *user) { + const char *cmd; + i_assert(src != NULL); i_assert(user->weak); @@ -577,10 +580,27 @@ orig_src->last_seq++; } - director_update_send(dir, src, t_strdup_printf( - "USER-WEAK\t%s\t%u\t%u\t%u\t%s\n", + cmd = t_strdup_printf("USER-WEAK\t%s\t%u\t%u\t%u\t%s\n", net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq, - user->username_hash, net_ip2addr(&user->host->ip))); + user->username_hash, net_ip2addr(&user->host->ip)); + + if (src != dir->self_host && dir->left != NULL && dir->right != NULL && + director_connection_get_host(dir->left) == + director_connection_get_host(dir->right)) { + /* only two directors in this ring and we're forwarding + USER-WEAK from one director back to itself via another + so it sees we've received it. we can't use + director_update_send() for this, because it doesn't send + data back to the source. */ + if (dir->right == src_conn) + director_connection_send(dir->left, cmd); + else if (dir->left == src_conn) + director_connection_send(dir->right, cmd); + else + i_unreached(); + } else { + director_update_send(dir, src, cmd); + } } struct director_user_kill_finish_ctx { diff -r 5162c2051642 -r 89c0689ab00b src/director/director.h --- a/src/director/director.h Thu May 08 11:29:34 2014 +0300 +++ b/src/director/director.h Wed Apr 23 23:26:49 2014 +0300 @@ -124,6 +124,7 @@ void director_update_user(struct director *dir, struct director_host *src, struct user *user); void director_update_user_weak(struct director *dir, struct director_host *src, + struct director_connection *src_conn, struct director_host *orig_src, struct user *user); void director_move_user(struct director *dir, struct director_host *src, From dovecot at dovecot.org Thu May 8 15:44:00 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 15:44:00 +0000 Subject: dovecot-2.2: Released v2.2.13.rc1. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/791ec610422c changeset: 17363:791ec610422c user: Timo Sirainen date: Thu May 08 18:07:23 2014 +0300 description: Released v2.2.13.rc1. diffstat: Makefile.am | 3 +-- NEWS | 33 +++++++++++++++++++++++++++++++++ configure.ac | 4 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) diffs (68 lines): diff -r 36c2611e053e -r 791ec610422c Makefile.am --- a/Makefile.am Thu May 08 15:53:27 2014 +0300 +++ b/Makefile.am Thu May 08 18:07:23 2014 +0300 @@ -76,9 +76,8 @@ uninstall-hook: rm $(DESTDIR)$(pkglibdir)/dovecot-config -CLEANFILES = $(datafiles) if HAVE_SYSTEMD -CLEANFILES += $systedmsystemunit_DATA +CLEANFILES = $systedmsystemunit_DATA endif DISTCLEANFILES = \ diff -r 36c2611e053e -r 791ec610422c NEWS --- a/NEWS Thu May 08 15:53:27 2014 +0300 +++ b/NEWS Thu May 08 18:07:23 2014 +0300 @@ -1,3 +1,36 @@ +v2.2.13 2014-05-xx Timo Sirainen + + * Fixed a DoS attack against imap/pop3-login processes. If SSL/TLS + handshake was started but wasn't finished, the login process + attempted to eventually forcibly disconnect the client, but failed + to do it correctly. This could have left the connections hanging + arond for a long time. (Affected Dovecot v1.1+) + + + mdbox: Added mdbox_purge_preserve_alt setting to keep the file + within alt storage during purge. (Should become enforced in v2.3.0?) + + fts: Added support for parsing attachments via Apache Tika. Enable + with: plugin { fts_tika = http://tikahost:9998/tika/ } + + virtual plugin: Delay opening backend mailboxes until it's necessary. + This requires mailbox_list_index=yes to work. (Currently IMAP IDLE + command still causes all backend mailboxes to be opened.) + + mail_never_cache_fields=* means now to disable all caching. This may + be a useful optimization as doveadm/dsync parameter for some admin + tasks which shouldn't really update the cache file. + + IMAP: Return SPECIAL-USE flags always for LSUB command. + - pop3 server was still crashing in v2.2.12 with some settings + - maildir: Various fixes and improvements to handling compressed mails, + especially when they have broken/missing S=sizes in filenames. + - fts-lucene, fts-solr: Fixed crash on search when the index contained + duplicate entries. + - Many fixes and performance improvements to dsync and replication + - director was somewhat broken when there were exactly two directors + in the ring. It caused errors about "weak users" getting stuck. + - mail_attachment_dir: Attachments with the last base64-encoded line + longer than the rest wasn't handled correctly. + - IMAP: SEARCH/SORT PARTIAL was handled completely wrong in v2.2.11+ + - acl: Global ACL file handling was broken when multiple entries + matched the mailbox name. (Only the first entry was used.) + v2.2.12 2014-02-14 Timo Sirainen - pop3 server was crashing in v2.2.11 diff -r 36c2611e053e -r 791ec610422c configure.ac --- a/configure.ac Thu May 08 15:53:27 2014 +0300 +++ b/configure.ac Thu May 08 18:07:23 2014 +0300 @@ -2,8 +2,8 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.12],[dovecot at dovecot.org]) -AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv11($PACKAGE_VERSION)", [Dovecot ABI version]) +AC_INIT([Dovecot],[2.2.13.rc1],[dovecot at dovecot.org]) +AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv13($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Thu May 8 15:44:00 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 15:44:00 +0000 Subject: dovecot-2.2: Added tag 2.2.13.rc1 for changeset 791ec610422c Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6b2eddd436cf changeset: 17364:6b2eddd436cf user: Timo Sirainen date: Thu May 08 18:07:23 2014 +0300 description: Added tag 2.2.13.rc1 for changeset 791ec610422c diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 791ec610422c -r 6b2eddd436cf .hgtags --- a/.hgtags Thu May 08 18:07:23 2014 +0300 +++ b/.hgtags Thu May 08 18:07:23 2014 +0300 @@ -116,3 +116,4 @@ 614bd66000113a062c1a02751cc7d04c0fcef1d6 2.2.10 6b96eb75ded21d09739c5662a52dd054059920f6 2.2.11 8e4433702920216747e874d2914518de6748d05f 2.2.12 +791ec610422cd2852cf51bd1842e90aa04d3ed20 2.2.13.rc1 From dovecot at dovecot.org Thu May 8 15:44:01 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 May 2014 15:44:01 +0000 Subject: dovecot-2.2: Added signature for changeset 791ec610422c Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f557dada0649 changeset: 17365:f557dada0649 user: Timo Sirainen date: Thu May 08 18:07:30 2014 +0300 description: Added signature for changeset 791ec610422c diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 6b2eddd436cf -r f557dada0649 .hgsigs --- a/.hgsigs Thu May 08 18:07:23 2014 +0300 +++ b/.hgsigs Thu May 08 18:07:30 2014 +0300 @@ -79,3 +79,4 @@ 614bd66000113a062c1a02751cc7d04c0fcef1d6 0 iEYEABECAAYFAlKzsg8ACgkQyUhSUUBVism5cACdEM1jR3c6gO0dGodbsgVtDMZPSxsAoKGmvyIxt7MSQkdz9cbe+Kfn2jyK 6b96eb75ded21d09739c5662a52dd054059920f6 0 iEYEABECAAYFAlL6qV8ACgkQyUhSUUBVislKhwCgm48QhoYeogfLdMT6Ys65XD8n93gAnA7xLoUqp8qXP9xhMrXabhaLQCaC 8e4433702920216747e874d2914518de6748d05f 0 iEYEABECAAYFAlL9OsoACgkQyUhSUUBVisnz6ACgmR2KgErDS5jB8SvPB2u7yaRN6SIAnRwxqa0LGPBM52Fdw2e8vDVFxSWU +791ec610422cd2852cf51bd1842e90aa04d3ed20 0 iEUEABECAAYFAlNrnasACgkQyUhSUUBVismrBQCUD5Q/tPiX+KtsoWM3aUOyooARWgCfcfUrhO5jUSBEXZ9F61wVynvtxf0= From pigeonhole at rename-it.nl Thu May 8 19:23:45 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 08 May 2014 21:23:45 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: program-client: Made sure tha... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2a8af66dc66a changeset: 1855:2a8af66dc66a user: Stephan Bosch date: Thu May 08 21:23:24 2014 +0200 description: lib-sieve: program-client: Made sure that programs are never forked with root privileges. diffstat: src/lib-sieve/util/program-client-local.c | 37 ++++++++++++++++ src/lib-sieve/util/program-client.h | 3 + src/plugins/sieve-extprograms/sieve-extprograms-common.c | 2 + 3 files changed, 42 insertions(+), 0 deletions(-) diffs (72 lines): diff -r dc038c03b376 -r 2a8af66dc66a src/lib-sieve/util/program-client-local.c --- a/src/lib-sieve/util/program-client-local.c Wed May 07 21:17:43 2014 +0200 +++ b/src/lib-sieve/util/program-client-local.c Thu May 08 21:23:24 2014 +0200 @@ -177,6 +177,43 @@ i_error("close(extra_fd[0]) failed: %m"); } + /* drop privileges if we have any */ + if ( getuid() == 0 ) { + uid_t uid; + gid_t gid; + + /* switch back to root */ + if (seteuid(0) < 0) + i_fatal("seteuid(0) failed: %m"); + + /* drop gid first */ + gid = getgid(); + if ( gid == 0 || gid != pclient->set.gid ) { + if ( pclient->set.gid != 0 ) { + if ( setgid(pclient->set.gid) < 0 ) + i_fatal("setgid(%d) failed: %m", pclient->set.gid); + } else { + gid = getegid(); + if (gid != 0 && setgid(gid) < 0) { + i_fatal("setgid(%d) failed: %m", gid); + } + } + } + + /* drop uid */ + if ( pclient->set.uid != 0 ) { + if ( setuid(pclient->set.uid) ) + i_fatal("setuid(%d) failed: %m", pclient->set.uid); + } else { + uid = geteuid(); + if ( uid != 0 && setuid(uid) < 0 ) + i_fatal("setuid(%d) failed: %m", uid); + } + } + + i_assert(getuid() != 0); + i_assert(getgid() != 0); + if ( array_is_created(&pclient->envs) ) envs = array_get(&pclient->envs, &count); diff -r dc038c03b376 -r 2a8af66dc66a src/lib-sieve/util/program-client.h --- a/src/lib-sieve/util/program-client.h Wed May 07 21:17:43 2014 +0200 +++ b/src/lib-sieve/util/program-client.h Thu May 08 21:23:24 2014 +0200 @@ -10,6 +10,9 @@ unsigned int client_connect_timeout_msecs; unsigned int input_idle_timeout_secs; + uid_t uid; + gid_t gid; + unsigned int debug:1; unsigned int drop_stderr:1; }; diff -r dc038c03b376 -r 2a8af66dc66a src/plugins/sieve-extprograms/sieve-extprograms-common.c --- a/src/plugins/sieve-extprograms/sieve-extprograms-common.c Wed May 07 21:17:43 2014 +0200 +++ b/src/plugins/sieve-extprograms/sieve-extprograms-common.c Thu May 08 21:23:24 2014 +0200 @@ -520,6 +520,8 @@ sprog->set.client_connect_timeout_msecs = SIEVE_EXTPROGRAMS_CONNECT_TIMEOUT_MSECS; sprog->set.input_idle_timeout_secs = ext_config->execute_timeout; + sprog->set.uid = senv->user->uid; + sprog->set.gid = senv->user->gid; sprog->set.debug = svinst->debug; if ( fork ) { From pigeonhole at rename-it.nl Thu May 8 20:28:59 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 08 May 2014 22:28:59 +0200 Subject: dovecot-1.2-managesieve: managesieve-login: SSL connections didn... Message-ID: details: http://hg.rename-it.nl/dovecot-1.2-managesieve/rev/711dbdabb434 changeset: 225:711dbdabb434 user: Stephan Bosch date: Thu May 08 22:28:51 2014 +0200 description: managesieve-login: SSL connections didn't get closed when the client got destroyed. diffstat: src/managesieve-login/client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 78d4860e22ce -r 711dbdabb434 src/managesieve-login/client.c --- a/src/managesieve-login/client.c Thu May 19 23:42:37 2011 +0200 +++ b/src/managesieve-login/client.c Thu May 08 22:28:51 2014 +0200 @@ -511,6 +511,8 @@ client_unlink(&client->common); + if (!client->login_success && client->common.proxy != NULL) + ssl_proxy_destroy(client->common.proxy); if (client->common.input != NULL) i_stream_close(client->common.input); if (client->output != NULL) From pigeonhole at rename-it.nl Thu May 8 23:33:01 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Fri, 09 May 2014 01:33:01 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: redirect: Adjusted loop detec... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/3b6917a4807c changeset: 1856:3b6917a4807c user: Stephan Bosch date: Fri May 09 01:32:52 2014 +0200 description: lib-sieve: redirect: Adjusted loop detection to show leniency to resent messages. diffstat: src/lib-sieve/cmd-redirect.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diffs (29 lines): diff -r 2a8af66dc66a -r 3b6917a4807c src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Thu May 08 21:23:24 2014 +0200 +++ b/src/lib-sieve/cmd-redirect.c Fri May 09 01:32:52 2014 +0200 @@ -386,13 +386,21 @@ const struct sieve_message_data *msgdata = aenv->msgdata; const struct sieve_script_env *senv = aenv->scriptenv; const char *orig_recipient = sieve_message_get_orig_recipient(aenv->msgctx); - const char *dupeid; + const char *dupeid = NULL, *resent_id = NULL, *resent_from = NULL; int ret; /* Prevent mail loops if possible */ - dupeid = msgdata->id == NULL ? NULL : t_strdup_printf - ("%s-%s-%s", msgdata->id, orig_recipient, ctx->to_address); - if (dupeid != NULL) { + (void)mail_get_first_header(msgdata->mail, "resent-message-id", &resent_id); + if ( msgdata->id != NULL || resent_id != NULL ) { + if ( resent_id == NULL ) + (void)mail_get_first_header(msgdata->mail, "resent-from", &resent_from); + dupeid = t_strdup_printf("%s-%s-%s-%s", + (msgdata->id == NULL ? "" : msgdata->id), + orig_recipient, ctx->to_address, + (resent_id != NULL ? + resent_id : (resent_from == NULL ? "" : resent_from))); + } + if ( dupeid != NULL ) { /* Check whether we've seen this message before */ if (sieve_action_duplicate_check(senv, dupeid, strlen(dupeid))) { sieve_result_global_log(aenv, "discarded duplicate forward to <%s>", From pigeonhole at rename-it.nl Fri May 9 06:55:09 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Fri, 09 May 2014 08:55:09 +0200 Subject: dovecot-2.2-pigeonhole: testsuite: editheader: Made test failure... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/9f8a3411090a changeset: 1857:9f8a3411090a user: Stephan Bosch date: Fri May 09 08:55:02 2014 +0200 description: testsuite: editheader: Made test failure messages a bit more verbose. diffstat: tests/extensions/editheader/addheader.svtest | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diffs (35 lines): diff -r 3b6917a4807c -r 9f8a3411090a tests/extensions/editheader/addheader.svtest --- a/tests/extensions/editheader/addheader.svtest Fri May 09 01:32:52 2014 +0200 +++ b/tests/extensions/editheader/addheader.svtest Fri May 09 08:55:02 2014 +0200 @@ -436,11 +436,13 @@ } if not header :is "x-some-header-first" "${before_out}" { - test_fail "wrong first content added"; + if header :matches "x-some-header-first" "*" {} + test_fail "wrong first content added: `${0}`"; } if not header :is "x-some-header-last" "${after_out}" { - test_fail "wrong last content added"; + if header :matches "x-some-header-last" "*" {} + test_fail "wrong last content added: `${0}`"; } redirect "frop at example.com"; @@ -466,11 +468,13 @@ } if not header :is "x-some-header-first" "${before_out}" { - test_fail "wrong first header content in redirected mail "; + if header :matches "x-some-header-first" "*" {} + test_fail "wrong first header content in redirected mail: `${0}`"; } if not header :is "x-some-header-last" "${after_out}" { - test_fail "wrong last header content in redirected mail "; + if header :matches "x-some-header-last" "*" {} + test_fail "wrong last header content in redirected mail: `${0}`"; } if not body :matches "Frop!*" { From dovecot at dovecot.org Sun May 11 15:28:58 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 15:28:58 +0000 Subject: dovecot-2.2: lib-mail: message_header_encode() no longer tries t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4892a941d63b changeset: 17366:4892a941d63b user: Timo Sirainen date: Sun May 11 18:28:03 2014 +0300 description: lib-mail: message_header_encode() no longer tries to lookup the first line's length from output string. This function is used only by Pigeonhole, which only uses it for empty output strings, so it's not useful there. Also that behavior is somewhat unexpected and confusing. diffstat: src/lib-mail/message-header-encode.c | 32 +++++--------------------------- src/lib-mail/message-header-encode.h | 3 +-- 2 files changed, 6 insertions(+), 29 deletions(-) diffs (76 lines): diff -r f557dada0649 -r 4892a941d63b src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Thu May 08 18:07:30 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Sun May 11 18:28:03 2014 +0300 @@ -28,29 +28,13 @@ return FALSE; } -static unsigned int str_last_line_len(string_t *str) -{ - const unsigned char *data = str_data(str); - unsigned int i = str_len(str); - - while (i > 0 && data[i-1] != '\n') - i--; - return str_len(str) - i; -} - void message_header_encode_q(const unsigned char *input, unsigned int len, string_t *output) { - unsigned int i, line_len, line_len_left; - - line_len = str_last_line_len(output); - if (line_len >= MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - 3) { - str_append(output, "\n\t"); - line_len = 1; - } + unsigned int i, line_len_left; str_append(output, "=?utf-8?q?"); - line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - line_len; + line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN; for (i = 0; i < len; i++) { if (line_len_left < 3) { /* if we're not at the beginning of a character, @@ -90,16 +74,10 @@ void message_header_encode_b(const unsigned char *input, unsigned int len, string_t *output) { - unsigned int line_len, line_len_left, max; + unsigned int line_len_left, max; - line_len = str_last_line_len(output); - if (line_len >= MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN) { - str_append(output, "\n\t"); - line_len = 1; - } - + line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN; for (;;) { - line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - line_len; max = MAX_BASE64_DECODED_SIZE(line_len_left); do { max--; @@ -127,7 +105,7 @@ break; str_append(output, "\n\t"); - line_len = 1; + line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - 1; } } diff -r f557dada0649 -r 4892a941d63b src/lib-mail/message-header-encode.h --- a/src/lib-mail/message-header-encode.h Thu May 08 18:07:30 2014 +0300 +++ b/src/lib-mail/message-header-encode.h Sun May 11 18:28:03 2014 +0300 @@ -7,8 +7,7 @@ string_t *output); /* Encode the whole UTF-8 input using "Q" or "B" encoding into output. - The output is split into multiple lines if necessary. The first line length - is looked up from the output string. */ + The output is split into multiple lines if necessary (max 76 chars/line). */ void message_header_encode_q(const unsigned char *input, unsigned int len, string_t *output); void message_header_encode_b(const unsigned char *input, unsigned int len, From dovecot at dovecot.org Sun May 11 18:10:19 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 18:10:19 +0000 Subject: dovecot-2.2: lib-mail: message_header_encode_[bq]() now explicit... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/009caac530e9 changeset: 17367:009caac530e9 user: Timo Sirainen date: Sun May 11 21:08:51 2014 +0300 description: lib-mail: message_header_encode_[bq]() now explicitly takes the first line length parameter. So this change partially reverts the previous change, because message_header_encode() was actually internally relying on this behavior. The explicit parameter makes it clearer. diffstat: src/lib-mail/message-header-encode.c | 37 ++++++++++++++++++++++-------- src/lib-mail/message-header-encode.h | 10 +++++--- src/lib-mail/test-message-header-encode.c | 6 +++- 3 files changed, 37 insertions(+), 16 deletions(-) diffs (123 lines): diff -r 4892a941d63b -r 009caac530e9 src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Sun May 11 18:28:03 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Sun May 11 21:08:51 2014 +0300 @@ -29,12 +29,20 @@ } void message_header_encode_q(const unsigned char *input, unsigned int len, - string_t *output) + string_t *output, unsigned int first_line_len) { unsigned int i, line_len_left; + line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN; + + if (first_line_len >= MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - 3) { + str_append(output, "\n\t"); + line_len_left--; + } else { + line_len_left -= first_line_len; + } + str_append(output, "=?utf-8?q?"); - line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN; for (i = 0; i < len; i++) { if (line_len_left < 3) { /* if we're not at the beginning of a character, @@ -72,12 +80,18 @@ } void message_header_encode_b(const unsigned char *input, unsigned int len, - string_t *output) + string_t *output, unsigned int first_line_len) { - unsigned int line_len_left, max; + unsigned int line_len, line_len_left, max; - line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN; + line_len = first_line_len; + if (line_len >= MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN) { + str_append(output, "\n\t"); + line_len = 1; + } + for (;;) { + line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - line_len; max = MAX_BASE64_DECODED_SIZE(line_len_left); do { max--; @@ -105,7 +119,7 @@ break; str_append(output, "\n\t"); - line_len_left = MIME_MAX_LINE_LEN - MIME_WRAPPER_LEN - 1; + line_len = 1; } } @@ -155,9 +169,12 @@ /* and do it */ str_append_data(output, input, first_idx); - if (use_q) - message_header_encode_q(input + first_idx, enc_len, output); - else - message_header_encode_b(input + first_idx, enc_len, output); + if (use_q) { + message_header_encode_q(input + first_idx, enc_len, + output, first_idx); + } else { + message_header_encode_b(input + first_idx, enc_len, + output, first_idx); + } str_append_data(output, input + last_idx, len - last_idx); } diff -r 4892a941d63b -r 009caac530e9 src/lib-mail/message-header-encode.h --- a/src/lib-mail/message-header-encode.h Sun May 11 18:28:03 2014 +0300 +++ b/src/lib-mail/message-header-encode.h Sun May 11 21:08:51 2014 +0300 @@ -1,16 +1,18 @@ #ifndef MESSAGE_HEADER_ENCODE_H #define MESSAGE_HEADER_ENCODE_H -/* Encode UTF-8 input into output wherever necessary. */ +/* Encode UTF-8 input into output wherever necessary using either Q or B + encoding depending on which takes less space (approximately). */ void message_header_encode(const char *input, string_t *output); void message_header_encode_data(const unsigned char *input, unsigned int len, string_t *output); /* Encode the whole UTF-8 input using "Q" or "B" encoding into output. - The output is split into multiple lines if necessary (max 76 chars/line). */ + The output is split into multiple lines if necessary (max 76 chars/line). + The first line's length is given as parameter. */ void message_header_encode_q(const unsigned char *input, unsigned int len, - string_t *output); + string_t *output, unsigned int first_line_len); void message_header_encode_b(const unsigned char *input, unsigned int len, - string_t *output); + string_t *output, unsigned int first_line_len); #endif diff -r 4892a941d63b -r 009caac530e9 src/lib-mail/test-message-header-encode.c --- a/src/lib-mail/test-message-header-encode.c Sun May 11 18:28:03 2014 +0300 +++ b/src/lib-mail/test-message-header-encode.c Sun May 11 21:08:51 2014 +0300 @@ -67,7 +67,8 @@ str_append_c(str, ' '); message_header_encode_q(str_data(input) + skip, - str_len(input) - skip, str); + str_len(input) - skip, str, + i == 0 ? 0 : i+1); test_assert(verify_q(str_c(str), i, !skip)); } } @@ -153,7 +154,8 @@ str_append_c(str, ' '); message_header_encode_b(str_data(input) + skip, - str_len(input) - skip, str); + str_len(input) - skip, str, + i == 0 ? 0 : i+1); test_assert(verify_b(str_c(str), i, !skip)); } } From dovecot at dovecot.org Sun May 11 19:20:02 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:20:02 +0000 Subject: dovecot-2.2: lib-mail: message_header_encode() now preserves fol... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e6c96db70cfb changeset: 17368:e6c96db70cfb user: Timo Sirainen date: Sun May 11 22:15:08 2014 +0300 description: lib-mail: message_header_encode() now preserves folding whitespace This function could still use some cleaning up, but good enough for now.. Also it should try to minimize the encoded words, not necessarily encoding everything between the first and the last words that have to be encoded. diffstat: src/lib-mail/message-header-encode.c | 134 +++++++++++++++++++++++------ src/lib-mail/message-header-encode.h | 7 +- src/lib-mail/test-message-header-encode.c | 21 ++++- 3 files changed, 130 insertions(+), 32 deletions(-) diffs (235 lines): diff -r 009caac530e9 -r e6c96db70cfb src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Sun May 11 21:08:51 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Sun May 11 22:15:08 2014 +0300 @@ -14,17 +14,44 @@ static bool input_idx_need_encoding(const unsigned char *input, unsigned int i, unsigned int len) { - /* 8bit chars */ - if ((input[i] & 0x80) != 0) - return TRUE; - /* control chars */ - if (input[i] < 32) - return TRUE; - - /* =? */ - if (input[i] == '=' && i+1 < len && input[i+1] == '?' && - (i == 0 || IS_LWSP(input[i-1]))) - return TRUE; + switch (input[i]) { + case '\r': + if (i+1 == len || input[i+1] != '\n') + return TRUE; + i++; + /* fall through and verify the LF as well */ + case '\n': + if (i+1 == len) { + /* trailing LF - we need to drop it */ + return TRUE; + } + if (input[i+1] != '\t' && input[i+1] != ' ') { + /* LF not followed by whitespace - we need to + add the whitespace */ + return TRUE; + } + break; + case '\t': + /* TAB doesn't need to be encoded */ + break; + case '=': + /* =? - we need to check backwards a bit to see if + there is LWSP (note that we don't want to return TRUE for + the LWSP itself yet, so we need to do this backwards + check) */ + if ((i == 0 || IS_LWSP(input[i-1])) && i+2 <= len && + memcmp(input + i, "=?", 2) == 0) + return TRUE; + break; + default: + /* 8bit chars */ + if ((input[i] & 0x80) != 0) + return TRUE; + /* control chars */ + if (input[i] < 32) + return TRUE; + break; + } return FALSE; } @@ -45,9 +72,9 @@ str_append(output, "=?utf-8?q?"); for (i = 0; i < len; i++) { if (line_len_left < 3) { - /* if we're not at the beginning of a character, + /* if we're not at the beginning of an UTF8 character, go backwards until we are */ - while ((input[i] & 0xc0) == 0x80) { + while (i > 0 && (input[i] & 0xc0) == 0x80) { str_truncate(output, str_len(output)-3); i--; } @@ -131,9 +158,11 @@ void message_header_encode_data(const unsigned char *input, unsigned int len, string_t *output) { - unsigned int i, first_idx, last_idx; + unsigned int i, j, first_line_len, cur_line_len, last_idx; unsigned int enc_chars, enc_len, base64_len, q_len; - bool use_q; + const unsigned char *next_line_input; + unsigned int next_line_len; + bool use_q, cr; /* find the first word that needs encoding */ for (i = 0; i < len; i++) { @@ -145,13 +174,36 @@ str_append_data(output, input, len); return; } - first_idx = i; - while (first_idx > 0 && !IS_LWSP(input[first_idx-1])) - first_idx--; + /* go back to the beginning of the word so it is fully encoded */ + if (input[i] != '\r' && input[i] != '\n') { + while (i > 0 && !IS_LWSP(input[i-1])) + i--; + } + + /* write the prefix */ + str_append_data(output, input, i); + first_line_len = j = i; + while (j > 0 && input[j-1] != '\n') j--; + if (j != 0) + first_line_len = j; + + input += i; + len -= i; + + /* we'll encode data only up to the next LF, the rest is handled + recursively. */ + next_line_input = memchr(input, '\n', len); + if (next_line_input != NULL) { + if (next_line_input != input && next_line_input[-1] == '\r') + next_line_input--; + cur_line_len = next_line_input - input; + next_line_len = len - cur_line_len; + len = cur_line_len; + } /* find the last word that needs encoding */ - last_idx = ++i; enc_chars = 1; - for (; i < len; i++) { + last_idx = 0; enc_chars = 0; + for (i = 0; i < len; i++) { if (input_idx_need_encoding(input, i, len)) { last_idx = i + 1; enc_chars++; @@ -162,19 +214,43 @@ /* figure out if we should use Q or B encoding. Prefer Q if it's not too much larger. */ - enc_len = last_idx - first_idx; + enc_len = last_idx; base64_len = MAX_BASE64_ENCODED_SIZE(enc_len); q_len = enc_len + enc_chars*3; use_q = q_len*2/3 <= base64_len; /* and do it */ - str_append_data(output, input, first_idx); - if (use_q) { - message_header_encode_q(input + first_idx, enc_len, - output, first_idx); - } else { - message_header_encode_b(input + first_idx, enc_len, - output, first_idx); + if (enc_len == 0) + ; + else if (use_q) + message_header_encode_q(input, enc_len, output, first_line_len); + else + message_header_encode_b(input, enc_len, output, first_line_len); + str_append_data(output, input + last_idx, len - last_idx); + + if (next_line_input != NULL) { + /* we're at [CR]LF */ + i = 0; + if (next_line_input[0] == '\r') { + cr = TRUE; + i++; + } + i_assert(next_line_input[i] == '\n'); + if (++i == next_line_len) + return; /* drop trailing [CR]LF */ + + if (cr) + str_append_c(output, '\r'); + str_append_c(output, '\n'); + + if (next_line_input[i] == ' ' || next_line_input[i] == '\t') { + str_append_c(output, next_line_input[i]); + i++; + } else { + /* make it valid folding whitespace by adding a TAB */ + str_append_c(output, '\t'); + } + message_header_encode_data(next_line_input+i, next_line_len-i, + output); } - str_append_data(output, input + last_idx, len - last_idx); } diff -r 009caac530e9 -r e6c96db70cfb src/lib-mail/message-header-encode.h --- a/src/lib-mail/message-header-encode.h Sun May 11 21:08:51 2014 +0300 +++ b/src/lib-mail/message-header-encode.h Sun May 11 22:15:08 2014 +0300 @@ -2,14 +2,17 @@ #define MESSAGE_HEADER_ENCODE_H /* Encode UTF-8 input into output wherever necessary using either Q or B - encoding depending on which takes less space (approximately). */ + encoding depending on which takes less space (approximately). Folding + whitespace is preserved. Bare [CR]LF will be preserved by adding a TAB + after it to make it a valid folding whitespace. */ void message_header_encode(const char *input, string_t *output); void message_header_encode_data(const unsigned char *input, unsigned int len, string_t *output); /* Encode the whole UTF-8 input using "Q" or "B" encoding into output. The output is split into multiple lines if necessary (max 76 chars/line). - The first line's length is given as parameter. */ + The first line's length is given as parameter. All the control characters + are encoded, including NUL, CR and LF. */ void message_header_encode_q(const unsigned char *input, unsigned int len, string_t *output, unsigned int first_line_len); void message_header_encode_b(const unsigned char *input, unsigned int len, diff -r 009caac530e9 -r e6c96db70cfb src/lib-mail/test-message-header-encode.c --- a/src/lib-mail/test-message-header-encode.c Sun May 11 21:08:51 2014 +0300 +++ b/src/lib-mail/test-message-header-encode.c Sun May 11 22:15:08 2014 +0300 @@ -170,8 +170,27 @@ "a ?? ? b", "a =?utf-8?b?w6TDpCDDpA==?= b", "? a ?", "=?utf-8?q?=C3=A4_a_=C3=A4?=", "?? a ?", "=?utf-8?b?w6TDpCBhIMOk?=", + "=", "=", + "?", "?", + "a=?", "a=?", + "=?", "=?utf-8?q?=3D=3F?=", + "=?x", "=?utf-8?q?=3D=3Fx?=", + "a\n=?", "a\n\t=?utf-8?q?=3D=3F?=", + "a\t=?", "a\t=?utf-8?q?=3D=3F?=", + "a =?", "a =?utf-8?q?=3D=3F?=", "foo\001bar", "=?utf-8?q?foo=01bar?=", - "\x01\x02\x03\x04\x05\x06\x07\x08", "=?utf-8?b?AQIDBAUGBwg=?=" + "\x01\x02\x03\x04\x05\x06\x07\x08", "=?utf-8?b?AQIDBAUGBwg=?=", + + "a\r\n b", "a\r\n b", + "a\r\n\tb", "a\r\n\tb", + "a\r\nb", "a\r\n\tb", + "a\n b", "a\n b", + "a\n b", "a\n b", + "a\nb", "a\n\tb", + "a\r\n", "a", + "a\n", "a", + "foo\n \001bar", "foo\n =?utf-8?q?=01bar?=", + "foo\001\n bar", "=?utf-8?q?foo=01?=\n bar" }; string_t *str = t_str_new(128); unsigned int i; From dovecot at dovecot.org Sun May 11 19:20:07 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:20:07 +0000 Subject: dovecot-2.2: doveadm penalty: Fixed using -a parameter Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2ea729128dbe changeset: 17369:2ea729128dbe user: Timo Sirainen date: Sun May 11 22:19:15 2014 +0300 description: doveadm penalty: Fixed using -a parameter diffstat: src/doveadm/doveadm-penalty.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r e6c96db70cfb -r 2ea729128dbe src/doveadm/doveadm-penalty.c --- a/src/doveadm/doveadm-penalty.c Sun May 11 22:15:08 2014 +0300 +++ b/src/doveadm/doveadm-penalty.c Sun May 11 22:19:15 2014 +0300 @@ -106,6 +106,7 @@ help(&doveadm_cmd_penalty); } } + argv += optind-1; if (argv[1] != NULL) { if (net_parse_range(argv[1], &ctx.net_ip, &ctx.net_bits) == 0) From dovecot at dovecot.org Sun May 11 19:32:56 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:32:56 +0000 Subject: dovecot-2.2: lib-mail: Fix to previous message_header_encode() c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3db2d96381ca changeset: 17370:3db2d96381ca user: Timo Sirainen date: Sun May 11 22:31:54 2014 +0300 description: lib-mail: Fix to previous message_header_encode() commit diffstat: src/lib-mail/message-header-encode.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 2ea729128dbe -r 3db2d96381ca src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Sun May 11 22:19:15 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Sun May 11 22:31:54 2014 +0300 @@ -234,6 +234,8 @@ if (next_line_input[0] == '\r') { cr = TRUE; i++; + } else { + cr = FALSE; } i_assert(next_line_input[i] == '\n'); if (++i == next_line_len) From dovecot at dovecot.org Sun May 11 19:32:56 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:32:56 +0000 Subject: dovecot-2.2: lib-mail: test-message-header-decoder unit test fixed Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/71f168f3b7e6 changeset: 17371:71f168f3b7e6 user: Timo Sirainen date: Sun May 11 22:32:19 2014 +0300 description: lib-mail: test-message-header-decoder unit test fixed diffstat: src/lib-mail/test-message-header-decode.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diffs (37 lines): diff -r 3db2d96381ca -r 71f168f3b7e6 src/lib-mail/test-message-header-decode.c --- a/src/lib-mail/test-message-header-decode.c Sun May 11 22:31:54 2014 +0300 +++ b/src/lib-mail/test-message-header-decode.c Sun May 11 22:32:19 2014 +0300 @@ -59,19 +59,30 @@ test_begin("message header encode & decode randomly"); - buf[0] = 'x'; encoded = t_str_new(256); decoded = t_str_new(256); for (i = 0; i < 1000; i++) { /* fill only with 7bit data so we don't have to worry about the data being valid UTF-8 */ - for (j = 1; j < sizeof(buf); j++) + for (j = 0; j < sizeof(buf); j++) buf[j] = rand() % 128; buflen = rand() % sizeof(buf); str_truncate(encoded, 0); str_truncate(decoded, 0); - message_header_encode_data(buf, buflen, encoded); + + /* test Q */ + message_header_encode_q(buf, buflen, encoded, 0); + message_header_decode_utf8(encoded->data, encoded->used, + decoded, NULL); + test_assert(decoded->used == buflen && + memcmp(decoded->data, buf, buflen) == 0); + + /* test B */ + str_truncate(encoded, 0); + str_truncate(decoded, 0); + + message_header_encode_b(buf, buflen, encoded, 0); message_header_decode_utf8(encoded->data, encoded->used, decoded, NULL); test_assert(decoded->used == buflen && From dovecot at dovecot.org Sun May 11 19:39:31 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:39:31 +0000 Subject: dovecot-2.2: Released v2.2.13. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c55c660d6e9d changeset: 17372:c55c660d6e9d user: Timo Sirainen date: Sun May 11 22:33:08 2014 +0300 description: Released v2.2.13. diffstat: NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 71f168f3b7e6 -r c55c660d6e9d NEWS --- a/NEWS Sun May 11 22:32:19 2014 +0300 +++ b/NEWS Sun May 11 22:33:08 2014 +0300 @@ -1,4 +1,4 @@ -v2.2.13 2014-05-xx Timo Sirainen +v2.2.13 2014-05-11 Timo Sirainen * Fixed a DoS attack against imap/pop3-login processes. If SSL/TLS handshake was started but wasn't finished, the login process diff -r 71f168f3b7e6 -r c55c660d6e9d configure.ac --- a/configure.ac Sun May 11 22:32:19 2014 +0300 +++ b/configure.ac Sun May 11 22:33:08 2014 +0300 @@ -2,7 +2,7 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.13.rc1],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.13],[dovecot at dovecot.org]) AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv13($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Sun May 11 19:39:37 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:39:37 +0000 Subject: dovecot-2.2: Added tag 2.2.13 for changeset c55c660d6e9d Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0802fa398c25 changeset: 17373:0802fa398c25 user: Timo Sirainen date: Sun May 11 22:33:08 2014 +0300 description: Added tag 2.2.13 for changeset c55c660d6e9d diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r c55c660d6e9d -r 0802fa398c25 .hgtags --- a/.hgtags Sun May 11 22:33:08 2014 +0300 +++ b/.hgtags Sun May 11 22:33:08 2014 +0300 @@ -117,3 +117,4 @@ 6b96eb75ded21d09739c5662a52dd054059920f6 2.2.11 8e4433702920216747e874d2914518de6748d05f 2.2.12 791ec610422cd2852cf51bd1842e90aa04d3ed20 2.2.13.rc1 +c55c660d6e9dd0b433768c906c1462cf6e8d71d5 2.2.13 From dovecot at dovecot.org Sun May 11 19:39:37 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:39:37 +0000 Subject: dovecot-2.2: Added signature for changeset c55c660d6e9d Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2392c1c0c751 changeset: 17374:2392c1c0c751 user: Timo Sirainen date: Sun May 11 22:33:21 2014 +0300 description: Added signature for changeset c55c660d6e9d diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 0802fa398c25 -r 2392c1c0c751 .hgsigs --- a/.hgsigs Sun May 11 22:33:08 2014 +0300 +++ b/.hgsigs Sun May 11 22:33:21 2014 +0300 @@ -80,3 +80,4 @@ 6b96eb75ded21d09739c5662a52dd054059920f6 0 iEYEABECAAYFAlL6qV8ACgkQyUhSUUBVislKhwCgm48QhoYeogfLdMT6Ys65XD8n93gAnA7xLoUqp8qXP9xhMrXabhaLQCaC 8e4433702920216747e874d2914518de6748d05f 0 iEYEABECAAYFAlL9OsoACgkQyUhSUUBVisnz6ACgmR2KgErDS5jB8SvPB2u7yaRN6SIAnRwxqa0LGPBM52Fdw2e8vDVFxSWU 791ec610422cd2852cf51bd1842e90aa04d3ed20 0 iEUEABECAAYFAlNrnasACgkQyUhSUUBVismrBQCUD5Q/tPiX+KtsoWM3aUOyooARWgCfcfUrhO5jUSBEXZ9F61wVynvtxf0= +c55c660d6e9dd0b433768c906c1462cf6e8d71d5 0 iEYEABECAAYFAlNv0HUACgkQyUhSUUBVisllBwCePV2jKcugiF0QYnIFLGJytMsW22kAn2bGBQ5hD/LrpTml5h9aCchkpSL3 From dovecot at dovecot.org Sun May 11 19:53:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 May 2014 19:53:23 +0000 Subject: dovecot-2.2: lib-mail: Compiler warning fix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6bb26098a45c changeset: 17375:6bb26098a45c user: Timo Sirainen date: Sun May 11 22:52:30 2014 +0300 description: lib-mail: Compiler warning fix diffstat: src/lib-mail/message-header-encode.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2392c1c0c751 -r 6bb26098a45c src/lib-mail/message-header-encode.c --- a/src/lib-mail/message-header-encode.c Sun May 11 22:33:21 2014 +0300 +++ b/src/lib-mail/message-header-encode.c Sun May 11 22:52:30 2014 +0300 @@ -161,7 +161,7 @@ unsigned int i, j, first_line_len, cur_line_len, last_idx; unsigned int enc_chars, enc_len, base64_len, q_len; const unsigned char *next_line_input; - unsigned int next_line_len; + unsigned int next_line_len = 0; bool use_q, cr; /* find the first word that needs encoding */ From dovecot at dovecot.org Mon May 12 09:19:39 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 May 2014 09:19:39 +0000 Subject: dovecot-2.2: acl: Empty negative rights list should be the same ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/daa0b8e5cf2e changeset: 17376:daa0b8e5cf2e user: Timo Sirainen date: Mon May 12 12:18:46 2014 +0300 description: acl: Empty negative rights list should be the same as NULL negative rights list. There may be other places where this should be fixed, but this at least fixes errors with dsync where "-user" entry without any rights was attempted to be synced in dovecot-acl (although such entry shouldn't really have existed in the first place). diffstat: src/plugins/acl/acl-api.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 6bb26098a45c -r daa0b8e5cf2e src/plugins/acl/acl-api.c --- a/src/plugins/acl/acl-api.c Sun May 11 22:52:30 2014 +0300 +++ b/src/plugins/acl/acl-api.c Mon May 12 12:18:46 2014 +0300 @@ -363,7 +363,7 @@ if (rights->rights != NULL) str_append(str, t_strarray_join(rights->rights, " ")); - if (rights->neg_rights != NULL) { + if (rights->neg_rights != NULL && rights->neg_rights[0] != NULL) { if (str_len(str) > 0) str_append_c(str, ' '); str_append_c(str, '-'); From dovecot at dovecot.org Mon May 12 09:53:46 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 May 2014 09:53:46 +0000 Subject: dovecot-2.2: dsync: mailbox_metadata.cache_fields must be copied... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a21ac1261487 changeset: 17377:a21ac1261487 user: Timo Sirainen date: Mon May 12 12:51:50 2014 +0300 description: dsync: mailbox_metadata.cache_fields must be copied to permanent memory. Any other call to mailbox_get_metadata() would have cleared the memory. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 34 ++++++++++++++++++++++++++++++++- src/doveadm/dsync/dsync-brain-private.h | 1 + src/doveadm/dsync/dsync-brain.c | 3 ++ 3 files changed, 37 insertions(+), 1 deletions(-) diffs (89 lines): diff -r daa0b8e5cf2e -r a21ac1261487 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Mon May 12 12:18:46 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Mon May 12 12:51:50 2014 +0300 @@ -60,6 +60,24 @@ return 0; } +static void +dsync_mailbox_cache_field_dup(ARRAY_TYPE(mailbox_cache_field) *dest, + const ARRAY_TYPE(mailbox_cache_field) *src, + pool_t pool) +{ + const struct mailbox_cache_field *src_field; + struct mailbox_cache_field *dest_field; + + p_array_init(dest, pool, array_count(src)); + array_foreach(src, src_field) { + dest_field = array_append_space(dest); + dest_field->name = p_strdup(pool, src_field->name); + dest_field->decision = src_field->decision; + dest_field->last_used = src_field->last_used; + } +} + + static const struct dsync_mailbox_state * dsync_mailbox_state_find(struct dsync_brain *brain, const guid_128_t mailbox_guid) @@ -122,6 +140,15 @@ dsync_brain_sync_init_box_states(brain); } brain->local_dsync_box = *local_dsync_box; + if (brain->dsync_box_pool != NULL) + p_clear(brain->dsync_box_pool); + else { + brain->dsync_box_pool = + pool_alloconly_create("dsync brain box pool", 1024); + } + dsync_mailbox_cache_field_dup(&brain->local_dsync_box.cache_fields, + &local_dsync_box->cache_fields, + brain->dsync_box_pool); memset(&brain->remote_dsync_box, 0, sizeof(brain->remote_dsync_box)); state = dsync_mailbox_state_find(brain, local_dsync_box->mailbox_guid); @@ -154,6 +181,9 @@ sizeof(remote_dsync_box->mailbox_guid)) == 0); brain->remote_dsync_box = *remote_dsync_box; + dsync_mailbox_cache_field_dup(&brain->remote_dsync_box.cache_fields, + &remote_dsync_box->cache_fields, + brain->dsync_box_pool); state = dsync_mailbox_state_find(brain, remote_dsync_box->mailbox_guid); if (state != NULL) { @@ -338,7 +368,9 @@ dsync_box_r->first_recent_uid = status.first_recent_uid; dsync_box_r->highest_modseq = status.highest_modseq; dsync_box_r->highest_pvt_modseq = status.highest_pvt_modseq; - dsync_box_r->cache_fields = *metadata.cache_fields; + dsync_mailbox_cache_field_dup(&dsync_box_r->cache_fields, + metadata.cache_fields, + pool_datastack_create()); dsync_box_r->have_guids = status.have_guids; dsync_box_r->have_save_guids = status.have_save_guids; dsync_box_r->have_only_guid128 = status.have_only_guid128; diff -r daa0b8e5cf2e -r a21ac1261487 src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Mon May 12 12:18:46 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain-private.h Mon May 12 12:51:50 2014 +0300 @@ -77,6 +77,7 @@ struct mailbox *box; struct dsync_mailbox local_dsync_box, remote_dsync_box; + pool_t dsync_box_pool; /* list of mailbox states for master brain: given to brain at init and for slave brain: received from DSYNC_STATE_SLAVE_RECV_LAST_COMMON */ diff -r daa0b8e5cf2e -r a21ac1261487 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Mon May 12 12:18:46 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Mon May 12 12:51:50 2014 +0300 @@ -299,6 +299,9 @@ hash_table_iterate_deinit(&brain->mailbox_states_iter); hash_table_destroy(&brain->mailbox_states); + if (brain->dsync_box_pool != NULL) + pool_unref(&brain->dsync_box_pool); + if (brain->lock_fd != -1) { /* unlink the lock file before it gets unlocked */ if (unlink(brain->lock_path) < 0) From dovecot at dovecot.org Mon May 12 10:22:10 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 May 2014 10:22:10 +0000 Subject: dovecot-2.2: dsync: If incremental sync fails because of desync,... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1aa94368ab28 changeset: 17378:1aa94368ab28 user: Timo Sirainen date: Mon May 12 13:21:28 2014 +0300 description: dsync: If incremental sync fails because of desync, log the reason why diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 41 ++++++++++++++++++++----- src/doveadm/dsync/dsync-transaction-log-scan.c | 9 ++++- src/doveadm/dsync/dsync-transaction-log-scan.h | 3 +- 3 files changed, 41 insertions(+), 12 deletions(-) diffs (119 lines): diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Mon May 12 12:51:50 2014 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Mon May 12 13:21:28 2014 +0300 @@ -230,6 +230,8 @@ enum dsync_mailbox_exporter_flags exporter_flags = 0; uint32_t last_common_uid, highest_wanted_uid; uint64_t last_common_modseq, last_common_pvt_modseq; + const char *desync_reason = ""; + bool pvt_too_old; int ret; i_assert(brain->log_scan == NULL); @@ -245,31 +247,52 @@ highest_wanted_uid, last_common_modseq, last_common_pvt_modseq, - &brain->log_scan); + &brain->log_scan, &pvt_too_old); if (ret < 0) { i_error("Failed to read transaction log for mailbox %s", mailbox_get_vname(brain->box)); brain->failed = TRUE; return -1; } + if (ret == 0) { + if (pvt_too_old) { + desync_reason = t_strdup_printf( + "Private modseq %llu no longer in transaction log", + (unsigned long long)last_common_pvt_modseq); + } else { + desync_reason = t_strdup_printf( + "Modseq %llu no longer in transaction log", + (unsigned long long)last_common_modseq); + } + } if (last_common_uid != 0) { mailbox_get_open_status(brain->box, STATUS_UIDNEXT | STATUS_HIGHESTMODSEQ | STATUS_HIGHESTPVTMODSEQ, &status); - if (status.uidnext < last_common_uid || - status.highest_modseq < last_common_modseq || - status.highest_pvt_modseq < last_common_pvt_modseq) { - /* last_common_* is higher than our current ones. - incremental sync state is stale, we need to do - a full resync */ + /* if last_common_* is higher than our current ones it means + that the incremental sync state is stale and we need to do + a full resync */ + if (status.uidnext < last_common_uid) { + desync_reason = t_strdup_printf("uidnext %u < %u", + status.uidnext, last_common_uid); + ret = 0; + } else if (status.highest_modseq < last_common_modseq) { + desync_reason = t_strdup_printf("highest_modseq %llu < %llu", + (unsigned long long)status.highest_modseq, + (unsigned long long)last_common_modseq); + ret = 0; + } else if (status.highest_pvt_modseq < last_common_pvt_modseq) { + desync_reason = t_strdup_printf("highest_pvt_modseq %llu < %llu", + (unsigned long long)status.highest_pvt_modseq, + (unsigned long long)last_common_pvt_modseq); ret = 0; } } if (ret == 0) { i_warning("Failed to do incremental sync for mailbox %s, " - "retry with a full sync", - mailbox_get_vname(brain->box)); + "retry with a full sync (%s)", + mailbox_get_vname(brain->box), desync_reason); brain->changes_during_sync = TRUE; brain->require_full_resync = TRUE; return 0; diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-transaction-log-scan.c --- a/src/doveadm/dsync/dsync-transaction-log-scan.c Mon May 12 12:51:50 2014 +0300 +++ b/src/doveadm/dsync/dsync-transaction-log-scan.c Mon May 12 13:21:28 2014 +0300 @@ -506,12 +506,15 @@ struct mail_index_view *pvt_view, uint32_t highest_wanted_uid, uint64_t modseq, uint64_t pvt_modseq, - struct dsync_transaction_log_scan **scan_r) + struct dsync_transaction_log_scan **scan_r, + bool *pvt_too_old_r) { struct dsync_transaction_log_scan *ctx; pool_t pool; int ret, ret2; + *pvt_too_old_r = FALSE; + pool = pool_alloconly_create(MEMPOOL_GROWING"dsync transaction log scan", 10240); ctx = p_new(pool, struct dsync_transaction_log_scan, 1); @@ -528,8 +531,10 @@ if (pvt_view != NULL) { if ((ret2 = dsync_log_scan(ctx, pvt_view, pvt_modseq, TRUE)) < 0) return -1; - if (ret2 == 0) + if (ret2 == 0) { ret = 0; + *pvt_too_old_r = TRUE; + } } *scan_r = ctx; diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-transaction-log-scan.h --- a/src/doveadm/dsync/dsync-transaction-log-scan.h Mon May 12 12:51:50 2014 +0300 +++ b/src/doveadm/dsync/dsync-transaction-log-scan.h Mon May 12 13:21:28 2014 +0300 @@ -14,7 +14,8 @@ struct mail_index_view *pvt_view, uint32_t highest_wanted_uid, uint64_t modseq, uint64_t pvt_modseq, - struct dsync_transaction_log_scan **scan_r); + struct dsync_transaction_log_scan **scan_r, + bool *pvt_too_old_r); HASH_TABLE_TYPE(dsync_uid_mail_change) dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan); HASH_TABLE_TYPE(dsync_attr_change) From pigeonhole at rename-it.nl Mon May 12 18:40:48 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 20:40:48 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: sieve-error.c: Made static an... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/f5fa3549de0d changeset: 1859:f5fa3549de0d user: Stephan Bosch date: Mon May 12 20:40:39 2014 +0200 description: lib-sieve: sieve-error.c: Made static analyzer happier. diffstat: src/lib-sieve/sieve-error.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diffs (65 lines): diff -r 5b41f1bca5ca -r f5fa3549de0d src/lib-sieve/sieve-error.c --- a/src/lib-sieve/sieve-error.c Mon May 12 20:22:30 2014 +0200 +++ b/src/lib-sieve/sieve-error.c Mon May 12 20:40:39 2014 +0200 @@ -78,6 +78,7 @@ { if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 && (ehandler == NULL || ehandler->parent == NULL)) { + i_assert(svinst->system_ehandler != NULL); if (svinst->system_ehandler != ehandler || (flags & SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO) != 0) { va_list args_copy; @@ -118,6 +119,7 @@ { if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 && (ehandler == NULL || ehandler->parent == NULL)) { + i_assert(svinst->system_ehandler != NULL); if (svinst->system_ehandler != ehandler || (flags & SIEVE_ERROR_FLAG_GLOBAL_MAX_INFO) != 0) { va_list args_copy; @@ -156,14 +158,16 @@ { if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 && (ehandler == NULL || ehandler->parent == NULL) && - svinst->system_ehandler != ehandler && - svinst->system_ehandler->vinfo != NULL ) { - va_list args_copy; + svinst->system_ehandler != ehandler) { + i_assert(svinst->system_ehandler != NULL); + if (svinst->system_ehandler->vinfo != NULL ) { + va_list args_copy; - VA_COPY(args_copy, args); + VA_COPY(args_copy, args); - svinst->system_ehandler->vinfo - (svinst->system_ehandler, 0, location, fmt, args_copy); + svinst->system_ehandler->vinfo + (svinst->system_ehandler, 0, location, fmt, args_copy); + } } if ( ehandler == NULL ) @@ -181,14 +185,16 @@ { if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 && (ehandler == NULL || ehandler->parent == NULL) && - svinst->system_ehandler != ehandler && - svinst->system_ehandler->vdebug != NULL ) { - va_list args_copy; + svinst->system_ehandler != ehandler) { + i_assert(svinst->system_ehandler != NULL); + if (svinst->system_ehandler->vdebug != NULL ) { + va_list args_copy; - VA_COPY(args_copy, args); + VA_COPY(args_copy, args); - svinst->system_ehandler->vdebug - (svinst->system_ehandler, 0, location, fmt, args_copy); + svinst->system_ehandler->vdebug + (svinst->system_ehandler, 0, location, fmt, args_copy); + } } if ( ehandler == NULL ) From pigeonhole at rename-it.nl Mon May 12 18:40:48 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 20:40:48 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: include extension: Fixed prob... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/5b41f1bca5ca changeset: 1858:5b41f1bca5ca user: Stephan Bosch date: Mon May 12 20:22:30 2014 +0200 description: lib-sieve: include extension: Fixed problem with handling of duplicate includes. Flags weren't actually updated. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 13 ++++--------- src/lib-sieve/plugins/include/ext-include-binary.h | 7 +++---- src/lib-sieve/plugins/include/ext-include-common.c | 9 +++++---- 3 files changed, 12 insertions(+), 17 deletions(-) diffs (83 lines): diff -r 9f8a3411090a -r 5b41f1bca5ca src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Fri May 09 08:55:02 2014 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Mon May 12 20:22:30 2014 +0200 @@ -124,7 +124,7 @@ * Script inclusion */ -const struct ext_include_script_info *ext_include_binary_script_include +struct ext_include_script_info *ext_include_binary_script_include (struct ext_include_binary_context *binctx, enum ext_include_script_location location, enum ext_include_flags flags, struct sieve_script *script, struct sieve_binary_block *inc_block) @@ -148,18 +148,13 @@ return incscript; } -bool ext_include_binary_script_is_included -(struct ext_include_binary_context *binctx, struct sieve_script *script, - const struct ext_include_script_info **script_info_r) +struct ext_include_script_info *ext_include_binary_script_get_include_info +(struct ext_include_binary_context *binctx, struct sieve_script *script) { struct ext_include_script_info *incscript = hash_table_lookup(binctx->included_scripts, script); - if ( incscript == NULL ) - return FALSE; - - *script_info_r = incscript; - return TRUE; + return incscript; } const struct ext_include_script_info *ext_include_binary_script_get_included diff -r 9f8a3411090a -r 5b41f1bca5ca src/lib-sieve/plugins/include/ext-include-binary.h --- a/src/lib-sieve/plugins/include/ext-include-binary.h Fri May 09 08:55:02 2014 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.h Mon May 12 20:22:30 2014 +0200 @@ -39,13 +39,12 @@ struct sieve_binary_block *block; }; -const struct ext_include_script_info *ext_include_binary_script_include +struct ext_include_script_info *ext_include_binary_script_include (struct ext_include_binary_context *binctx, enum ext_include_script_location location, enum ext_include_flags flags, struct sieve_script *script, struct sieve_binary_block *inc_block); -bool ext_include_binary_script_is_included - (struct ext_include_binary_context *binctx, struct sieve_script *script, - const struct ext_include_script_info **script_info_r); +struct ext_include_script_info *ext_include_binary_script_get_include_info + (struct ext_include_binary_context *binctx, struct sieve_script *script); const struct ext_include_script_info *ext_include_binary_script_get_included (struct ext_include_binary_context *binctx, unsigned int include_id); diff -r 9f8a3411090a -r 5b41f1bca5ca src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Fri May 09 08:55:02 2014 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Mon May 12 20:22:30 2014 +0200 @@ -471,7 +471,7 @@ ext_include_get_generator_context(this_ext, gentr); struct ext_include_generator_context *pctx; struct sieve_error_handler *ehandler = sieve_generator_error_handler(gentr); - const struct ext_include_script_info *included; + struct ext_include_script_info *included; *included_r = NULL; @@ -516,12 +516,13 @@ binctx = ext_include_binary_init(this_ext, sbin, cgenv->ast); /* Is the script already compiled into the current binary? */ - if ( ext_include_binary_script_is_included(binctx, script, &included) ) { + included = ext_include_binary_script_get_include_info(binctx, script); + if ( included != NULL ) { /* Yes, only update flags */ if ( (flags & EXT_INCLUDE_FLAG_OPTIONAL) == 0 ) - flags &= ~EXT_INCLUDE_FLAG_OPTIONAL; + included->flags &= ~EXT_INCLUDE_FLAG_OPTIONAL; if ( (flags & EXT_INCLUDE_FLAG_ONCE) == 0 ) - flags &= ~EXT_INCLUDE_FLAG_ONCE; + included->flags &= ~EXT_INCLUDE_FLAG_ONCE; } else { const char *script_name = sieve_script_name(script); enum sieve_compile_flags cpflags = cgenv->flags; From pigeonhole at rename-it.nl Mon May 12 19:13:01 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 21:13:01 +0200 Subject: dovecot-2.2-pigeonhole: Released v0.4.3 for Dovecot v2.2.13. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/1c6130ff5dd6 changeset: 1860:1c6130ff5dd6 user: Stephan Bosch date: Mon May 12 21:12:24 2014 +0200 description: Released v0.4.3 for Dovecot v2.2.13. diffstat: NEWS | 31 +++++++++++++++++++++++++++++++ configure.ac | 2 +- 2 files changed, 32 insertions(+), 1 deletions(-) diffs (47 lines): diff -r f5fa3549de0d -r 1c6130ff5dd6 NEWS --- a/NEWS Mon May 12 20:40:39 2014 +0200 +++ b/NEWS Mon May 12 21:12:24 2014 +0200 @@ -1,3 +1,34 @@ +v0.4.3 12-05-2013 Stephan Bosch + + * Editheader extension: Made control characters allowed for editheader, except + NUL. Before, this would cause a runtime error. + + Upgraded Dovecot-specific Sieve "vnd.dovecot.duplicate" extension to match + the new draft "duplicate" extension. + - Fixed sieve_result_global_log_error to log only as i_info in administrator + log (syslog) if executed from multiscript context. + - Sieve redirect extension: Adjusted loop detection to show leniency to resent + messages. + - Sieve include extension: Fixed problem with handling of duplicate includes + with different parameters :once or :optional. + - Sieve spamtest/virustest extensions: Tests were erroneously performed + against the original message. When used together with extprograms filter to + add the spam headers, the changes were not being used by the spamtest and + virustest extensions. + - Deprecated Sieve notify extension: Fixed segfault problems in message string + substitution. + - ManageSieve: Fixed active link verification to handle redundant path slashes + correctly. + - Sieve vacation extension: + - Fixed interaction of sieve_vacation_dont_check_recipient with + sieve_vacation_send_from_recipient setting. + - Fixed log message for discarded response. + - Sieve extprograms plugin: + - Forgot to disable the alarm() timeouts set for script execution. + - Fixed fd leak and handling of output shutdown. + - Fixed 'Bad filedescriptor' error occurring when disconnecting script + client. + - Made sure that programs are never forked with root privileges. + v0.4.2 26-09-2013 Stephan Bosch * Incompatible change in Sieve doveadm plugin: the root attribute for diff -r f5fa3549de0d -r 1c6130ff5dd6 configure.ac --- a/configure.ac Mon May 12 20:40:39 2014 +0200 +++ b/configure.ac Mon May 12 21:12:24 2014 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.4.2], [dovecot at dovecot.org], [dovecot-2.2-pigeonhole]) +AC_INIT([Pigeonhole], [0.4.3], [dovecot at dovecot.org], [dovecot-2.2-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Mon May 12 19:13:01 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 21:13:01 +0200 Subject: dovecot-2.2-pigeonhole: Added tag 0.4.3 for changeset 1c6130ff5dd6 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b3534d40784e changeset: 1861:b3534d40784e user: Stephan Bosch date: Mon May 12 21:12:34 2014 +0200 description: Added tag 0.4.3 for changeset 1c6130ff5dd6 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 1c6130ff5dd6 -r b3534d40784e .hgtags --- a/.hgtags Mon May 12 21:12:24 2014 +0200 +++ b/.hgtags Mon May 12 21:12:34 2014 +0200 @@ -19,3 +19,4 @@ 3a8dc1250e9b850044acbcd9d63d63597e67c7cb 0.4.0 f1535e2255cd84849d8b4fad6d82bdd6e01f810f 0.4.1 2176d400eca4fa5d89597793a09c0b194eaed05f 0.4.2 +1c6130ff5dd6933f03a40666b7f73ae51c9f90fe 0.4.3 From pigeonhole at rename-it.nl Mon May 12 19:14:55 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 21:14:55 +0200 Subject: dovecot-2.2-pigeonhole: Added signature for changeset 1c6130ff5dd6 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/5e8822097e7b changeset: 1862:5e8822097e7b user: Stephan Bosch date: Mon May 12 21:14:44 2014 +0200 description: Added signature for changeset 1c6130ff5dd6 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r b3534d40784e -r 5e8822097e7b .hgsigs --- a/.hgsigs Mon May 12 21:12:34 2014 +0200 +++ b/.hgsigs Mon May 12 21:14:44 2014 +0200 @@ -13,3 +13,4 @@ 3a8dc1250e9b850044acbcd9d63d63597e67c7cb 0 iQEcBAABAgAGBQJRi6eKAAoJEATWKx49+7T0+3sIAKj87rGC9kakJPL4RyFDc762HueCez8mUTRhe62K9+2LzVJL+2inGPY33PL5F7xZd0H/pxIfNfk/WGA78q6BkOaJSlGtz+wb5H/iZzSc+6GRfzPavlXlENgOKtnmzf3AoEKc0iNnieB5oYJTkJ2GtbPv2GD4u/Y6w7eTISfh/HlJeGvybR3L4XT6scNCr90/iQWjoZMNZSbYvKInSmrN9SGgtg0exqFfdkFmMahhSO/PGBq4hi5ZyFKqsnYEZpkLOduKW86nsn1GZiPD5/bEUD7lxJeeoRk3aobZoMQUlz4VRma6ag0MPRLpmzqUQFhpvDzpdg3dZSw/8NUQBa78w1M= f1535e2255cd84849d8b4fad6d82bdd6e01f810f 0 iQEcBAABAgAGBQJR1IRdAAoJEATWKx49+7T0uKMIANauBvbSO72bhrg8EI3Cvr2qy5nZrgqdgtZI0ZtIHbRBa9aBmxbX5lGqjWNLZaXwLc9dk7aeDoZds73kjiCYB+ac3UaXBaRscKNArkigTKFE0L2UZ5X5T/76iJ6diPFs8Eo/4ajYERDa3UQgUqHJ/8Fe2884bFDXMRmjbtVu2ceCw8Dlkee4kiVfjzuPRWud2jjtXcCoJXkFIQSbGcKsjlhd2yAGToJ9iw06tPNAFjupht9/wozyaZiZqJj7AnNvflHGMO1FDhOQJYxjz9JYA61h9F1vytGwfm1n3BVANpWSBJtkkuM/Tjp9GxeDB2jNrUbMikicSUceNtRLg9i0b+A= 2176d400eca4fa5d89597793a09c0b194eaed05f 0 iQEcBAABAgAGBQJSRI5JAAoJEATWKx49+7T0kGcIAKNHvRh/4idzHekHk5L81e0nu1IZRLyXg6YLkviF52ZYsB4WSbsiVhVYGoVS0XdSCvouQFq//In5S8nkUaSc1r4/2VK/vEchisYxwnF0YyLz5o7CaixLBCARLGGbjZTCyHvqOCHj6sRTJtc7GP1cdFXzYo7yIGg+W1hZn7yBB32p6stE+9SurxinK312LGFvBRrJ9t7y9gIeP1aV9yd0AhTorAP0XsOMflNQnnxsNXR/8LhwsqpOt9TR8hTVdGZHi2ZqjqK37/XAGYAJpBvpQRFq2UPWj6fEGNRLsh9TzGodQh/RoESvTeoHpEVy5o2yHUcnY71bYfMpb2IJH7NHKAA= +1c6130ff5dd6933f03a40666b7f73ae51c9f90fe 0 iQEcBAABAgAGBQJTcR2fAAoJEATWKx49+7T0tcwIANUB68pzhOoVHY/BhReqVfFLJCZLdDpsTFYkPhS99lcI4LwTNrNDe4OjpNNdk3UESOvUi19pIzDCewXSkk1gVAK4CGFbYNgvLpaX+8xjfBiPv8Ct47ALCISpT74TCMXR8t+tQ3jqaPFD/0j7tAt3sP9vYDNKt1QJ8YLSH1z9aSEYng+LJT9rZxMkw6/SnZw4GVFmQyuPWFBEe7oBE/RdURvQ+i+luuBIs7BaJWe3HkMD9giEafxHzBtib4QDSUOeloUOl+7ezeBJDxdcp+CzbjU4J0QfpokuU8YhEEnnzZ+9x+Tmmnv04qzB5BP8msVVCldxfymQdGx/qxCLj26H6Uk= From pigeonhole at rename-it.nl Mon May 12 19:27:20 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 12 May 2014 21:27:20 +0200 Subject: dovecot-2.2-pigeonhole: Wrong date in NEWS. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/689db87e26f2 changeset: 1863:689db87e26f2 user: Stephan Bosch date: Mon May 12 21:27:13 2014 +0200 description: Wrong date in NEWS. diffstat: NEWS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (9 lines): diff -r 5e8822097e7b -r 689db87e26f2 NEWS --- a/NEWS Mon May 12 21:14:44 2014 +0200 +++ b/NEWS Mon May 12 21:27:13 2014 +0200 @@ -1,4 +1,4 @@ -v0.4.3 12-05-2013 Stephan Bosch +v0.4.3 12-05-2014 Stephan Bosch * Editheader extension: Made control characters allowed for editheader, except NUL. Before, this would cause a runtime error. From dovecot at dovecot.org Tue May 13 13:46:39 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 May 2014 13:46:39 +0000 Subject: dovecot-2.2: lib-storage: Don't leak memory if mailbox_save_set_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8d1dcd28ee11 changeset: 17379:8d1dcd28ee11 user: Timo Sirainen date: Tue May 13 15:46:01 2014 +0200 description: lib-storage: Don't leak memory if mailbox_save_set_flags() is used multiple times for keywords. This affected only some external plugins. diffstat: src/lib-storage/mail-storage.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 1aa94368ab28 -r 8d1dcd28ee11 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Mon May 12 13:21:28 2014 +0300 +++ b/src/lib-storage/mail-storage.c Tue May 13 15:46:01 2014 +0200 @@ -1930,6 +1930,9 @@ { struct mailbox *box = ctx->transaction->box; + if (ctx->data.keywords != NULL) + mailbox_keywords_unref(&ctx->data.keywords); + ctx->data.flags = flags & ~mailbox_get_private_flags_mask(box); ctx->data.pvt_flags = flags & mailbox_get_private_flags_mask(box); ctx->data.keywords = keywords; From dovecot at dovecot.org Wed May 14 09:29:08 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 14 May 2014 09:29:08 +0000 Subject: dovecot-2.2: lib-fs: Make sure we don't leak data stack. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7c737fc7e54 changeset: 17380:e7c737fc7e54 user: Timo Sirainen date: Wed May 14 12:28:17 2014 +0300 description: lib-fs: Make sure we don't leak data stack. diffstat: src/lib-fs/fs-api.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diffs (46 lines): diff -r 8d1dcd28ee11 -r e7c737fc7e54 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue May 13 15:46:01 2014 +0200 +++ b/src/lib-fs/fs-api.c Wed May 14 12:28:17 2014 +0300 @@ -143,7 +143,9 @@ } i_free(fs->temp_path_prefix); - fs->v.deinit(fs); + T_BEGIN { + fs->v.deinit(fs); + } T_END; str_free(&last_error); } @@ -242,11 +244,16 @@ int fs_get_metadata(struct fs_file *file, const ARRAY_TYPE(fs_metadata) **metadata_r) { + int ret; + if (file->fs->v.get_metadata == NULL) { fs_set_error(file->fs, "Metadata not supported by backend"); return -1; } - return file->fs->v.get_metadata(file, metadata_r); + T_BEGIN { + ret = file->fs->v.get_metadata(file, metadata_r); + } T_END; + return ret; } const char *fs_file_path(struct fs_file *file) @@ -677,7 +684,12 @@ const char *fs_iter_next(struct fs_iter *iter) { - return iter->fs->v.iter_next(iter); + const char *ret; + + T_BEGIN { + ret = iter->fs->v.iter_next(iter); + } T_END; + return ret; } void fs_iter_set_async_callback(struct fs_iter *iter, From dovecot at dovecot.org Wed May 14 09:47:13 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 14 May 2014 09:47:13 +0000 Subject: dovecot-2.2: imap: Fixed enabling METADATA if imap_capability st... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c22c139b2823 changeset: 17381:c22c139b2823 user: Timo Sirainen date: Wed May 14 12:46:25 2014 +0300 description: imap: Fixed enabling METADATA if imap_capability string was explicitly set diffstat: src/imap/imap-client.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (17 lines): diff -r e7c737fc7e54 -r c22c139b2823 src/imap/imap-client.c --- a/src/imap/imap-client.c Wed May 14 12:28:17 2014 +0300 +++ b/src/imap/imap-client.c Wed May 14 12:46:25 2014 +0300 @@ -138,10 +138,10 @@ if (!explicit_capability) str_append(client->capability_string, " URLAUTH URLAUTH=BINARY"); } - if (set->imap_metadata && *mail_set->mail_attribute_dict != '\0' && - !explicit_capability) { + if (set->imap_metadata && *mail_set->mail_attribute_dict != '\0') { client->imap_metadata_enabled = TRUE; - str_append(client->capability_string, " METADATA"); + if (!explicit_capability) + str_append(client->capability_string, " METADATA"); } ident = mail_user_get_anvil_userip_ident(client->user); From dovecot at dovecot.org Thu May 15 10:27:20 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 May 2014 10:27:20 +0000 Subject: dovecot-2.2: virtual: If backend mailbox hasn't changed, we stil... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e99cd21e1f92 changeset: 17382:e99cd21e1f92 user: Timo Sirainen date: Thu May 15 13:26:40 2014 +0300 description: virtual: If backend mailbox hasn't changed, we still need to build its uidmap. diffstat: src/plugins/virtual/virtual-sync.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diffs (71 lines): diff -r c22c139b2823 -r e99cd21e1f92 src/plugins/virtual/virtual-sync.c --- a/src/plugins/virtual/virtual-sync.c Wed May 14 12:46:25 2014 +0300 +++ b/src/plugins/virtual/virtual-sync.c Thu May 15 13:26:40 2014 +0300 @@ -664,8 +664,10 @@ uidmap.virtual_uid = vuid; array_append(&bbox->uids, &uidmap, 1); - if (mail_index_lookup_seq(bbox->box->view, - vrec->real_uid, &seq)) { + if (result == NULL) + ; + else if (mail_index_lookup_seq(bbox->box->view, + vrec->real_uid, &seq)) { seq_range_array_add(&result->uids, vrec->real_uid); } else { @@ -1069,7 +1071,12 @@ status.uidnext == bbox->sync_next_uid && status.highest_modseq == bbox->sync_highest_modseq) { /* mailbox hasn't changed since we last opened it, - skip it for now. */ + skip it for now. + + we'll still need to create the bbox->uids mapping + using the current index. */ + if (array_count(&bbox->uids) == 0) + virtual_sync_backend_handle_old_vmsgs(ctx, bbox, NULL); return 0; } if (!bbox_index_opened) { @@ -1091,6 +1098,7 @@ /* build the initial search using the saved modseq. */ ret = virtual_sync_backend_box_continue(ctx, bbox); } + i_assert(bbox->search_result != NULL || ret < 0); } else { /* sync using the existing search result */ i_assert(bbox_index_opened); @@ -1144,6 +1152,8 @@ if (bbox == NULL || bbox->mailbox_id != vrec->mailbox_id) { /* add the rest of the newly seen messages */ + i_assert(j == uidmap_count || + bbox->search_result != NULL); for (; j < uidmap_count; j++) { add_rec.rec.real_uid = uidmap[j].real_uid; array_append(&ctx->all_adds, &add_rec, 1); @@ -1163,6 +1173,7 @@ } if (bbox->search_result == NULL) { /* mailbox is completely unchanged since last sync */ + j = uidmap_count; continue; } mail_index_lookup_uid(ctx->sync_view, vseq, &vuid); @@ -1254,6 +1265,7 @@ if (bbox == NULL || bbox->mailbox_id != vrec->mailbox_id) { bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id); + i_assert(bbox->search_result != NULL); } if (!mail_set_uid(bbox->sync_mail, vrec->real_uid)) i_unreached(); @@ -1299,6 +1311,7 @@ if (bbox == NULL || bbox->mailbox_id != vrec->mailbox_id) { bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id); + i_assert(bbox->search_result != NULL); } mail_index_append(ctx->trans, 0, &vseq); From pigeonhole at rename-it.nl Thu May 15 17:51:51 2014 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 May 2014 19:51:51 +0200 Subject: dovecot-2.2-pigeonhole: Fixed several problems reported by CLang... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/6a0376f1a7d2 changeset: 1864:6a0376f1a7d2 user: Stephan Bosch date: Thu May 15 19:48:27 2014 +0200 description: Fixed several problems reported by CLang 3.4. diffstat: src/lib-sieve/sieve-parser.c | 18 ------------------ src/lib-sieve/sieve.c | 2 +- src/lib-sieve/util/edit-mail.c | 16 +--------------- src/testsuite/testsuite-script.c | 2 +- 4 files changed, 3 insertions(+), 35 deletions(-) diffs (92 lines): diff -r 689db87e26f2 -r 6a0376f1a7d2 src/lib-sieve/sieve-parser.c --- a/src/lib-sieve/sieve-parser.c Mon May 12 21:27:13 2014 +0200 +++ b/src/lib-sieve/sieve-parser.c Thu May 15 19:48:27 2014 +0200 @@ -19,8 +19,6 @@ inline static void sieve_parser_error (struct sieve_parser *parser, const char *fmt, ...) ATTR_FORMAT(2, 3); -inline static void sieve_parser_warning - (struct sieve_parser *parser, const char *fmt, ...) ATTR_FORMAT(2, 3); static int sieve_parser_recover (struct sieve_parser *parser, enum sieve_token_type end_token); @@ -114,22 +112,6 @@ va_end(args); } -inline static void sieve_parser_warning -(struct sieve_parser *parser, const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - - T_BEGIN { - sieve_vwarning(parser->ehandler, - sieve_error_script_location(parser->script, - sieve_lexer_token_line(parser->lexer)), - fmt, args); - } T_END; - - va_end(args); -} - /* * Sieve grammar parsing */ diff -r 689db87e26f2 -r 6a0376f1a7d2 src/lib-sieve/sieve.c --- a/src/lib-sieve/sieve.c Mon May 12 21:27:13 2014 +0200 +++ b/src/lib-sieve/sieve.c Thu May 15 19:48:27 2014 +0200 @@ -274,7 +274,7 @@ sieve_ast_unref(&ast); if ( error_r != NULL ) - error_r = SIEVE_ERROR_NONE; + *error_r = SIEVE_ERROR_NONE; return sbin; } diff -r 689db87e26f2 -r 6a0376f1a7d2 src/lib-sieve/util/edit-mail.c --- a/src/lib-sieve/util/edit-mail.c Mon May 12 21:27:13 2014 +0200 +++ b/src/lib-sieve/util/edit-mail.c Thu May 15 19:48:27 2014 +0200 @@ -851,7 +851,7 @@ if ( index >= 0 ) { pos++; final = ( header_idx->last == field_idx ); - } else if ( index < 0 ) { + } else { pos--; final = ( header_idx->first == field_idx ); } @@ -945,20 +945,6 @@ *edhiter = NULL; } -static inline string_t *_header_right_trim(const char *raw) -{ - string_t *result; - int i; - - for ( i = strlen(raw)-1; i >= 0; i-- ) { - if ( raw[i] != ' ' && raw[i] != '\t' ) break; - } - - result = t_str_new(i+1); - str_append_n(result, raw, i + 1); - return result; -} - void edit_mail_headers_iterate_get (struct edit_mail_header_iter *edhiter, const char **value_r) { diff -r 689db87e26f2 -r 6a0376f1a7d2 src/testsuite/testsuite-script.c --- a/src/testsuite/testsuite-script.c Mon May 12 21:27:13 2014 +0200 +++ b/src/testsuite/testsuite-script.c Thu May 15 19:48:27 2014 +0200 @@ -42,7 +42,7 @@ script_path = sieve_file_script_get_dirpath(renv->script); if ( script_path == NULL ) - return SIEVE_EXEC_FAILURE; + return NULL; script_path = t_strconcat(script_path, "/", script, NULL); From dovecot at dovecot.org Thu May 15 20:42:52 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 May 2014 20:42:52 +0000 Subject: dovecot-2.2: lib-imap: Use case-insensitive comparisons everywhe... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/090c90714f59 changeset: 17383:090c90714f59 user: Timo Sirainen date: Thu May 15 23:41:55 2014 +0300 description: lib-imap: Use case-insensitive comparisons everywhere for imap_id_send setting parsing. "os" and "os-version" were case-sensitive while others were not. Patch by Apple. diffstat: src/lib-imap/imap-id.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (15 lines): diff -r e99cd21e1f92 -r 090c90714f59 src/lib-imap/imap-id.c --- a/src/lib-imap/imap-id.c Thu May 15 13:26:40 2014 +0300 +++ b/src/lib-imap/imap-id.c Thu May 15 23:41:55 2014 +0300 @@ -26,9 +26,9 @@ } } - if (strcmp(key, "os") == 0) + if (strcasecmp(key, "os") == 0) return utsname_result.sysname; - if (strcmp(key, "os-version") == 0) + if (strcasecmp(key, "os-version") == 0) return utsname_result.release; return NULL; } From dovecot at dovecot.org Wed May 21 13:22:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 May 2014 13:22:09 +0000 Subject: dovecot-2.2: lib: Added o_stream_is_corked(). Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8ab8327400cd changeset: 17384:8ab8327400cd user: Timo Sirainen date: Wed May 21 06:21:16 2014 -0700 description: lib: Added o_stream_is_corked(). diffstat: src/lib/ostream.c | 7 +++++++ src/lib/ostream.h | 1 + 2 files changed, 8 insertions(+), 0 deletions(-) diffs (28 lines): diff -r 090c90714f59 -r 8ab8327400cd src/lib/ostream.c --- a/src/lib/ostream.c Thu May 15 23:41:55 2014 +0300 +++ b/src/lib/ostream.c Wed May 21 06:21:16 2014 -0700 @@ -137,6 +137,13 @@ _stream->cork(_stream, FALSE); } +bool o_stream_is_corked(struct ostream *stream) +{ + struct ostream_private *_stream = stream->real_stream; + + return _stream->corked; +} + static void o_stream_clear_error(struct ostream *stream) { stream->stream_errno = 0; diff -r 090c90714f59 -r 8ab8327400cd src/lib/ostream.h --- a/src/lib/ostream.h Thu May 15 23:41:55 2014 +0300 +++ b/src/lib/ostream.h Wed May 21 06:21:16 2014 -0700 @@ -84,6 +84,7 @@ TCP_CORK on if supported. */ void o_stream_cork(struct ostream *stream); void o_stream_uncork(struct ostream *stream); +bool o_stream_is_corked(struct ostream *stream); /* Try to flush the output stream. Returns 1 if all sent, 0 if not, -1 if error. */ int o_stream_flush(struct ostream *stream); From dovecot at dovecot.org Wed May 21 13:29:28 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 May 2014 13:29:28 +0000 Subject: dovecot-2.2: imap: If we're waiting for client to read data, sho... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6b8620c6032c changeset: 17385:6b8620c6032c user: Timo Sirainen date: Wed May 21 06:28:36 2014 -0700 description: imap: If we're waiting for client to read data, show in process title how many bytes are buffered. diffstat: src/imap/imap-client.c | 2 ++ src/imap/main.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diffs (58 lines): diff -r 8ab8327400cd -r 6b8620c6032c src/imap/imap-client.c --- a/src/imap/imap-client.c Wed May 21 06:21:16 2014 -0700 +++ b/src/imap/imap-client.c Wed May 21 06:28:36 2014 -0700 @@ -942,6 +942,7 @@ } o_stream_uncork(output); o_stream_unref(&output); + imap_refresh_proctitle(); if (client->disconnected) client_destroy(client, NULL); @@ -1017,6 +1018,7 @@ (void)cmd_sync_delayed(client); o_stream_uncork(client->output); + imap_refresh_proctitle(); if (client->disconnected) client_destroy(client, NULL); else diff -r 8ab8327400cd -r 6b8620c6032c src/imap/main.c --- a/src/imap/main.c Wed May 21 06:21:16 2014 -0700 +++ b/src/imap/main.c Wed May 21 06:28:36 2014 -0700 @@ -51,6 +51,7 @@ struct client *client; struct client_command_context *cmd; string_t *title = t_str_new(128); + bool wait_output; if (!verbose_proctitle) return; @@ -67,14 +68,23 @@ str_append_c(title, ' '); str_append(title, net_ip2addr(client->user->remote_ip)); } + wait_output = FALSE; for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) { if (cmd->name == NULL) continue; - if (str_len(title) > IMAP_PROCTITLE_PREFERRED_LEN) - break; - str_append_c(title, ' '); - str_append(title, cmd->name); + if (str_len(title) < IMAP_PROCTITLE_PREFERRED_LEN) { + str_append_c(title, ' '); + str_append(title, cmd->name); + } + if (cmd->state == CLIENT_COMMAND_STATE_WAIT_OUTPUT) + wait_output = TRUE; + } + if (wait_output) { + str_printfa(title, " - %"PRIuSIZE_T" bytes waiting", + o_stream_get_buffer_used_size(client->output)); + if (o_stream_is_corked(client->output)) + str_append(title, " corked"); } break; default: From dovecot at dovecot.org Thu May 22 01:12:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 May 2014 01:12:53 +0000 Subject: dovecot-2.2: lib-storage: Added mailbox_list_index_very_dirty_sy... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a9966b4aa020 changeset: 17386:a9966b4aa020 user: Timo Sirainen date: Wed May 21 18:12:05 2014 -0700 description: lib-storage: Added mailbox_list_index_very_dirty_syncs setting. This setting assumes that the mailbox list index is up to date and uses it without stat()ing backend mailbox files/dirs. (As a possible future TODO it might be useful to still do the stat()ing, but only rarely.) diffstat: src/lib-storage/index/index-sync.c | 2 ++ src/lib-storage/index/maildir/maildir-sync-index.c | 4 +--- src/lib-storage/index/mbox/mbox-sync-list-index.c | 2 +- src/lib-storage/mail-storage-settings.c | 2 ++ src/lib-storage/mail-storage-settings.h | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diffs (69 lines): diff -r 6b8620c6032c -r a9966b4aa020 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Wed May 21 06:28:36 2014 -0700 +++ b/src/lib-storage/index/index-sync.c Wed May 21 18:12:05 2014 -0700 @@ -517,6 +517,8 @@ /* doesn't exist / not synced */ return 1; } + if (box->storage->set->mailbox_list_index_very_dirty_syncs) + return 0; ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &dir); if (ret < 0) diff -r 6b8620c6032c -r a9966b4aa020 src/lib-storage/index/maildir/maildir-sync-index.c --- a/src/lib-storage/index/maildir/maildir-sync-index.c Wed May 21 06:28:36 2014 -0700 +++ b/src/lib-storage/index/maildir/maildir-sync-index.c Wed May 21 18:12:05 2014 -0700 @@ -715,10 +715,8 @@ int ret; ret = index_storage_list_index_has_changed(box, list_view, seq); - if (ret != 0) + if (ret != 0 || box->storage->set->mailbox_list_index_very_dirty_syncs) return ret; - if (mbox->storage->set->maildir_very_dirty_syncs) - return 0; ext_id = maildir_list_get_ext_id(mbox, list_view); mail_index_lookup_ext(list_view, seq, ext_id, &data, &expunged); diff -r 6b8620c6032c -r a9966b4aa020 src/lib-storage/index/mbox/mbox-sync-list-index.c --- a/src/lib-storage/index/mbox/mbox-sync-list-index.c Wed May 21 06:28:36 2014 -0700 +++ b/src/lib-storage/index/mbox/mbox-sync-list-index.c Wed May 21 18:12:05 2014 -0700 @@ -32,7 +32,7 @@ int ret; ret = index_storage_list_index_has_changed(box, list_view, seq); - if (ret != 0) + if (ret != 0 || box->storage->set->mailbox_list_index_very_dirty_syncs) return ret; ext_id = mbox_list_get_ext_id(mbox, list_view); diff -r 6b8620c6032c -r a9966b4aa020 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Wed May 21 06:28:36 2014 -0700 +++ b/src/lib-storage/mail-storage-settings.c Wed May 21 18:12:05 2014 -0700 @@ -47,6 +47,7 @@ DEF(SET_BOOL, mail_nfs_storage), DEF(SET_BOOL, mail_nfs_index), DEF(SET_BOOL, mailbox_list_index), + DEF(SET_BOOL, mailbox_list_index_very_dirty_syncs), DEF(SET_BOOL, mail_debug), DEF(SET_BOOL, mail_full_filesystem_access), DEF(SET_BOOL, maildir_stat_dirs), @@ -84,6 +85,7 @@ .mail_nfs_storage = FALSE, .mail_nfs_index = FALSE, .mailbox_list_index = FALSE, + .mailbox_list_index_very_dirty_syncs = FALSE, .mail_debug = FALSE, .mail_full_filesystem_access = FALSE, .maildir_stat_dirs = FALSE, diff -r 6b8620c6032c -r a9966b4aa020 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Wed May 21 06:28:36 2014 -0700 +++ b/src/lib-storage/mail-storage-settings.h Wed May 21 18:12:05 2014 -0700 @@ -32,6 +32,7 @@ bool mail_nfs_storage; bool mail_nfs_index; bool mailbox_list_index; + bool mailbox_list_index_very_dirty_syncs; bool mail_debug; bool mail_full_filesystem_access; bool maildir_stat_dirs; From dovecot at dovecot.org Mon May 26 00:59:23 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 May 2014 00:59:23 +0000 Subject: dovecot-2.2: lib-storage: Optimize mailbox_exists() with mailbox... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e163a82b10f5 changeset: 17387:e163a82b10f5 user: Timo Sirainen date: Mon May 26 03:58:16 2014 +0300 description: lib-storage: Optimize mailbox_exists() with mailbox_list_index=yes We can return the existence from the index itself to avoid stat()s. diffstat: src/lib-storage/list/mailbox-list-index-status.c | 31 ++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diffs (48 lines): diff -r a9966b4aa020 -r e163a82b10f5 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Wed May 21 18:12:05 2014 -0700 +++ b/src/lib-storage/list/mailbox-list-index-status.c Mon May 26 03:58:16 2014 +0300 @@ -66,6 +66,36 @@ return 1; } +static int +index_list_exists(struct mailbox *box, bool auto_boxes, + enum mailbox_existence *existence_r) +{ + struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box); + struct mail_index_view *view; + const struct mail_index_record *rec; + enum mailbox_list_index_flags flags; + uint32_t seq; + int ret; + + if ((ret = index_list_open_view(box, &view, &seq)) <= 0) { + /* failure / not found. fallback to the real storage check + just in case to see if the mailbox was just created. */ + return ibox->module_ctx.super. + exists(box, auto_boxes, existence_r); + } + rec = mail_index_lookup(view, seq); + flags = rec->flags; + mail_index_view_close(&view); + + if ((flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0) + *existence_r = MAILBOX_EXISTENCE_NONE; + else if ((flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0) + *existence_r = MAILBOX_EXISTENCE_NOSELECT; + else + *existence_r = MAILBOX_EXISTENCE_SELECT; + return 0; +} + bool mailbox_list_index_status(struct mailbox_list *list, struct mail_index_view *view, uint32_t seq, enum mailbox_status_items items, @@ -532,6 +562,7 @@ void mailbox_list_index_status_init_mailbox(struct mailbox *box) { + box->v.exists = index_list_exists; box->v.get_status = index_list_get_status; box->v.get_metadata = index_list_get_metadata; box->v.sync_deinit = index_list_sync_deinit; From dovecot at dovecot.org Mon May 26 01:06:53 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 May 2014 01:06:53 +0000 Subject: dovecot-2.2: lib-storage: Avoid refreshing mailbox list index to... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/60d2cfdc3140 changeset: 17388:60d2cfdc3140 user: Timo Sirainen date: Mon May 26 04:05:34 2014 +0300 description: lib-storage: Avoid refreshing mailbox list index too often. diffstat: src/lib-storage/list/mailbox-list-index.c | 12 ++++++++++++ src/lib-storage/list/mailbox-list-index.h | 1 + 2 files changed, 13 insertions(+), 0 deletions(-) diffs (41 lines): diff -r e163a82b10f5 -r 60d2cfdc3140 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Mon May 26 03:58:16 2014 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Mon May 26 04:05:34 2014 +0300 @@ -366,7 +366,16 @@ if (ilist->syncing) return 0; + if (ilist->last_refresh_timeval.tv_usec == ioloop_timeval.tv_usec && + ilist->last_refresh_timeval.tv_sec == ioloop_timeval.tv_sec) { + /* we haven't been to ioloop since last refresh, skip checking + it. when we're accessing many mailboxes at once (e.g. + opening a virtual mailbox) we don't want to stat/read the + index every single time. */ + return 0; + } + ilist->last_refresh_timeval = ioloop_timeval; if (mailbox_list_index_index_open(list) < 0) return -1; if (mail_index_refresh(ilist->index) < 0) { @@ -401,6 +410,9 @@ struct mail_index_view *view; struct mail_index_transaction *trans; + memset(&ilist->last_refresh_timeval, 0, + sizeof(ilist->last_refresh_timeval)); + if (!ilist->has_backing_store) return; diff -r e163a82b10f5 -r 60d2cfdc3140 src/lib-storage/list/mailbox-list-index.h --- a/src/lib-storage/list/mailbox-list-index.h Mon May 26 03:58:16 2014 +0300 +++ b/src/lib-storage/list/mailbox-list-index.h Mon May 26 04:05:34 2014 +0300 @@ -86,6 +86,7 @@ const char *path; struct mail_index *index; uint32_t ext_id, msgs_ext_id, hmodseq_ext_id, subs_hdr_ext_id; + struct timeval last_refresh_timeval; pool_t mailbox_pool; /* uin32_t id => name */ From dovecot at dovecot.org Mon May 26 01:26:57 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 May 2014 01:26:57 +0000 Subject: dovecot-2.2: virtual: Crashfix: Don't deinitialize search args t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5c6f49e2d8d9 changeset: 17389:5c6f49e2d8d9 user: Timo Sirainen date: Mon May 26 04:26:01 2014 +0300 description: virtual: Crashfix: Don't deinitialize search args that haven't been initialized. diffstat: src/plugins/virtual/virtual-storage.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (16 lines): diff -r 60d2cfdc3140 -r 5c6f49e2d8d9 src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Mon May 26 04:05:34 2014 +0300 +++ b/src/plugins/virtual/virtual-storage.c Mon May 26 04:26:01 2014 +0300 @@ -249,8 +249,11 @@ if (bboxes[i]->box == NULL) continue; - if (bboxes[i]->search_args != NULL) + if (bboxes[i]->search_args != NULL && + bboxes[i]->search_args_initialized) { mail_search_args_deinit(bboxes[i]->search_args); + bboxes[i]->search_args_initialized = FALSE; + } mailbox_free(&bboxes[i]->box); if (array_is_created(&bboxes[i]->sync_outside_expunges)) array_free(&bboxes[i]->sync_outside_expunges); From dovecot at dovecot.org Tue May 27 14:02:16 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 14:02:16 +0000 Subject: dovecot-2.2: lib-http: Fixed assertion failure in http_client_re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/abffff2e916f changeset: 17390:abffff2e916f user: Stephan Bosch date: Tue May 27 17:01:15 2014 +0300 description: lib-http: Fixed assertion failure in http_client_request_send_payload() caused by inappropriate retry attempt. diffstat: src/lib-http/http-client-request.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 5c6f49e2d8d9 -r abffff2e916f src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Mon May 26 04:26:01 2014 +0300 +++ b/src/lib-http/http-client-request.c Tue May 27 17:01:15 2014 +0300 @@ -1004,6 +1004,13 @@ bool http_client_request_try_retry(struct http_client_request *req) { + /* don't ever retry if we're sending data in small blocks via + http_client_request_send_payload() and we're not waiting for a + 100 continue (there's no way to rewind the payload for a retry) + */ + if (req->payload_wait && + (!req->payload_sync || req->conn->payload_continue)) + return FALSE; /* limit the number of attempts for each request */ if (req->attempts+1 >= req->client->set.max_attempts) return FALSE; From dovecot at dovecot.org Tue May 27 18:19:03 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:03 +0000 Subject: dovecot-2.2: lib-storage: context's dotlock_last_stale really is... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b54844d64ee5 changeset: 17391:b54844d64ee5 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-storage: context's dotlock_last_stale really is bool It's only ever read as if it's a bool, so it really is a bool. Fix a write treating it as an int. Signed-off-by: Phil Carmody diffstat: src/lib-storage/index/mbox/mbox-lock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r abffff2e916f -r b54844d64ee5 src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Tue May 27 17:01:15 2014 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.c Tue May 27 21:17:34 2014 +0300 @@ -411,7 +411,7 @@ if (mbox->mbox_dotlocked) return 1; - ctx->dotlock_last_stale = -1; + ctx->dotlock_last_stale = TRUE; memset(&set, 0, sizeof(set)); set.use_excl_lock = mbox->storage->storage.set->dotlock_use_excl; From dovecot at dovecot.org Tue May 27 18:19:08 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:08 +0000 Subject: dovecot-2.2: lib-storage: functions returning bool actually retu... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/973b67dda572 changeset: 17392:973b67dda572 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-storage: functions returning bool actually return ints Their return values are compared as if they are at least tri-state (-ve, 0, +ve), so really aren't bools at all. Note - this should cause the code to change in behaviour, and thus might introduce regressions as previously all non-zeroes would have been mapped to 1. Signed-off-by: Phil Carmody diffstat: src/lib-storage/index/mbox/mbox-mail.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r b54844d64ee5 -r 973b67dda572 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Tue May 27 21:17:34 2014 +0300 @@ -149,7 +149,7 @@ return 0; } -static bool +static int mbox_mail_get_md5_header(struct index_mail *mail, const char **value_r) { struct mail *_mail = &mail->mail.mail; @@ -237,7 +237,7 @@ return index_mail_get_special(_mail, field, value_r); } -static bool +static int mbox_mail_get_next_offset(struct index_mail *mail, uoff_t *next_offset_r) { struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box; From dovecot at dovecot.org Tue May 27 18:19:08 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:08 +0000 Subject: dovecot-2.2: fts: parser-html - parse_tag_name really does retur... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8f68543fa7f8 changeset: 17393:8f68543fa7f8 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: fts: parser-html - parse_tag_name really does return an integer not a bool It seems to return 1 more than the number of additional characters (after '<') are swallowed up by the state change, not a bool. This would imply that '3' is wrong. diffstat: src/plugins/fts/fts-parser-html.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 973b67dda572 -r 8f68543fa7f8 src/plugins/fts/fts-parser-html.c --- a/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 +++ b/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 @@ -60,7 +60,7 @@ return &parser->parser; } -static bool +static size_t parse_tag_name(struct html_fts_parser *parser, const unsigned char *data, size_t size) { From dovecot at dovecot.org Tue May 27 18:19:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:09 +0000 Subject: dovecot-2.2: fts: parser-html - parse_tag_name returns wrong val... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/54e508b71dcd changeset: 17394:54e508b71dcd user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: fts: parser-html - parse_tag_name returns wrong value for comments This function returns 1 more than the number of additional characters to be swallowed up by the state transition. diffstat: src/plugins/fts/fts-parser-html.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 8f68543fa7f8 -r 54e508b71dcd src/plugins/fts/fts-parser-html.c --- a/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 +++ b/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 @@ -68,7 +68,7 @@ if (size >= 3 && memcmp(data, "!--", 3) == 0) { parser->state = HTML_STATE_COMMENT; - return 3; + return 3 + 1; } if (size > 5 && i_memcasecmp(data, "style", 5) == 0) { From dovecot at dovecot.org Tue May 27 18:19:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:09 +0000 Subject: dovecot-2.2: fts: parser-html - parser can fail on attributes='w... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ad028a950248 changeset: 17395:ad028a950248 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: fts: parser-html - parser can fail on attributes='with values in single quotes' If that value were to contain an odd number of double quotes, then the HTML_STATE_TAG_(D)QUOTED state would be entered and not exited. The two quoting types behave basically the same, so just add two new cases and duplicate the state transition code. diffstat: src/plugins/fts/fts-parser-html.c | 31 +++++++++++++++++++++++-------- 1 files changed, 23 insertions(+), 8 deletions(-) diffs (59 lines): diff -r 54e508b71dcd -r ad028a950248 src/plugins/fts/fts-parser-html.c --- a/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 +++ b/src/plugins/fts/fts-parser-html.c Tue May 27 21:17:34 2014 +0300 @@ -16,10 +16,14 @@ HTML_STATE_TEXT, /* tag outside "quoted string" */ HTML_STATE_TAG, - /* tag inside "quoted string" */ - HTML_STATE_TAG_QUOTED, + /* tag inside "double quoted string" */ + HTML_STATE_TAG_DQUOTED, /* tag -> "escape\ */ - HTML_STATE_TAG_QUOTED_ESCAPE, + HTML_STATE_TAG_DQUOTED_ESCAPE, + /* tag inside 'single quoted string' */ + HTML_STATE_TAG_SQUOTED, + /* tag -> 'escape\ */ + HTML_STATE_TAG_SQUOTED_ESCAPE, /* script/stype content */ HTML_STATE_IGNORE, /* comment */ @@ -171,21 +175,32 @@ break; case HTML_STATE_TAG: if (c == '"') - parser->state = HTML_STATE_TAG_QUOTED; + parser->state = HTML_STATE_TAG_DQUOTED; + else if (c == '\'') + parser->state = HTML_STATE_TAG_DQUOTED; else if (c == '>') { parser->state = parser->ignore_next_text ? HTML_STATE_IGNORE : HTML_STATE_TEXT; parser_add_space(parser); } break; - case HTML_STATE_TAG_QUOTED: + case HTML_STATE_TAG_DQUOTED: if (c == '"') parser->state = HTML_STATE_TAG; else if (c == '\\') - parser->state = HTML_STATE_TAG_QUOTED_ESCAPE; + parser->state = HTML_STATE_TAG_DQUOTED_ESCAPE; break; - case HTML_STATE_TAG_QUOTED_ESCAPE: - parser->state = HTML_STATE_TAG_QUOTED; + case HTML_STATE_TAG_DQUOTED_ESCAPE: + parser->state = HTML_STATE_TAG_DQUOTED; + break; + case HTML_STATE_TAG_SQUOTED: + if (c == '\'') + parser->state = HTML_STATE_TAG; + else if (c == '\\') + parser->state = HTML_STATE_TAG_SQUOTED_ESCAPE; + break; + case HTML_STATE_TAG_SQUOTED_ESCAPE: + parser->state = HTML_STATE_TAG_SQUOTED; break; case HTML_STATE_IGNORE: if (c == '<') { From dovecot at dovecot.org Tue May 27 18:19:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:09 +0000 Subject: dovecot-2.2: lib: pair VA_COPY with va_end Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/03870eea2857 changeset: 17396:03870eea2857 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib: pair VA_COPY with va_end A va_copy creates a initialised va_list, as if a va_start had been done on it. Therefore, pedantically, a va_end should also be done on it. On most platforms this is a no-op, and for those where it isn't, the pairing is important. Signed-off-by: Phil Carmody diffstat: src/lib/str.c | 1 + src/lib/strfuncs.c | 1 + src/master/main.c | 3 +++ 3 files changed, 5 insertions(+), 0 deletions(-) diffs (49 lines): diff -r ad028a950248 -r 03870eea2857 src/lib/str.c --- a/src/lib/str.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib/str.c Tue May 27 21:17:34 2014 +0300 @@ -170,6 +170,7 @@ ret2 = vsnprintf(tmp, ret + 1, fmt, args2); i_assert(ret2 == ret); } + va_end(args2); /* drop the unused data, including terminating NUL */ buffer_set_used_size(str, pos + ret); diff -r ad028a950248 -r 03870eea2857 src/lib/strfuncs.c --- a/src/lib/strfuncs.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib/strfuncs.c Tue May 27 21:17:34 2014 +0300 @@ -134,6 +134,7 @@ /* we rely on errno not changing. it shouldn't. */ i_assert(errno == old_errno); #endif + va_end(args2); return tmp; } diff -r ad028a950248 -r 03870eea2857 src/master/main.c --- a/src/master/main.c Tue May 27 21:17:34 2014 +0300 +++ b/src/master/main.c Tue May 27 21:17:34 2014 +0300 @@ -156,6 +156,7 @@ if (fd != -1) { VA_COPY(args2, args); str = t_strdup_vprintf(format, args2); + va_end(args2); (void)write_full(fd, str, strlen(str)); i_close_fd(&fd); } @@ -174,6 +175,7 @@ VA_COPY(args2, args); fprintf(stderr, "%s%s\n", failure_log_type_prefixes[ctx->type], t_strdup_vprintf(fmt, args2)); + va_end(args2); orig_fatal_callback(ctx, fmt, args); abort(); } @@ -187,6 +189,7 @@ VA_COPY(args2, args); fprintf(stderr, "%s%s\n", failure_log_type_prefixes[ctx->type], t_strdup_vprintf(fmt, args2)); + va_end(args2); orig_error_callback(ctx, fmt, args); } From dovecot at dovecot.org Tue May 27 18:19:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:09 +0000 Subject: dovecot-2.2: treewide - mass cleanup of 0 used to end a settings... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f373df52082a changeset: 17397:f373df52082a user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: treewide - mass cleanup of 0 used to end a settings list This also includes a change to the perl script which generates the all-settings.c file. Signed-off-by: Phil Carmody diffstat: src/anvil/anvil-settings.c | 2 +- src/auth/auth-settings.c | 4 ++-- src/config/config-settings.c | 2 +- src/config/settings-get.pl | 2 +- src/dict/dict-settings.c | 2 +- src/director/director-settings.c | 4 ++-- src/dns/dns-client-settings.c | 2 +- src/doveadm/doveadm-settings.c | 2 +- src/imap-login/imap-login-settings.c | 2 +- src/imap-urlauth/imap-urlauth-login-settings.c | 2 +- src/imap-urlauth/imap-urlauth-settings.c | 2 +- src/imap-urlauth/imap-urlauth-worker-settings.c | 2 +- src/imap/imap-settings.c | 2 +- src/indexer/indexer-settings.c | 2 +- src/indexer/indexer-worker-settings.c | 2 +- src/ipc/ipc-settings.c | 2 +- src/lmtp/lmtp-settings.c | 2 +- src/log/log-settings.c | 2 +- src/pop3-login/pop3-login-settings.c | 2 +- src/pop3/pop3-settings.c | 2 +- src/replication/aggregator/aggregator-settings.c | 4 ++-- src/replication/replicator/replicator-settings.c | 2 +- src/ssl-params/ssl-params-settings.c | 2 +- src/stats/stats-settings.c | 4 ++-- 24 files changed, 28 insertions(+), 28 deletions(-) diffs (truncated from 324 to 300 lines): diff -r 03870eea2857 -r f373df52082a src/anvil/anvil-settings.c --- a/src/anvil/anvil-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/anvil/anvil-settings.c Tue May 27 21:17:34 2014 +0300 @@ -17,7 +17,7 @@ &anvil_unix_listeners_array[1] }; static buffer_t anvil_unix_listeners_buf = { - anvil_unix_listeners, sizeof(anvil_unix_listeners), { 0, } + anvil_unix_listeners, sizeof(anvil_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/auth/auth-settings.c --- a/src/auth/auth-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/auth-settings.c Tue May 27 21:17:34 2014 +0300 @@ -32,7 +32,7 @@ &auth_unix_listeners_array[5] }; static buffer_t auth_unix_listeners_buf = { - auth_unix_listeners, sizeof(auth_unix_listeners), { 0, } + auth_unix_listeners, sizeof(auth_unix_listeners), { NULL, } }; /* */ @@ -72,7 +72,7 @@ &auth_worker_unix_listeners_array[0] }; static buffer_t auth_worker_unix_listeners_buf = { - auth_worker_unix_listeners, sizeof(auth_worker_unix_listeners), { 0, } + auth_worker_unix_listeners, sizeof(auth_worker_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/config/config-settings.c --- a/src/config/config-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/config/config-settings.c Tue May 27 21:17:34 2014 +0300 @@ -15,7 +15,7 @@ &config_unix_listeners_array[0] }; static buffer_t config_unix_listeners_buf = { - config_unix_listeners, sizeof(config_unix_listeners), { 0, } + config_unix_listeners, sizeof(config_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/config/settings-get.pl --- a/src/config/settings-get.pl Tue May 27 21:17:34 2014 +0300 +++ b/src/config/settings-get.pl Tue May 27 21:17:34 2014 +0300 @@ -132,7 +132,7 @@ } print "};\n"; print "buffer_t config_all_services_buf = {\n"; -print "\tconfig_all_services, sizeof(config_all_services), { 0, }\n"; +print "\tconfig_all_services, sizeof(config_all_services), { NULL, }\n"; print "};\n"; print "const struct setting_parser_info *all_default_roots[] = {\n"; diff -r 03870eea2857 -r f373df52082a src/dict/dict-settings.c --- a/src/dict/dict-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/dict/dict-settings.c Tue May 27 21:17:34 2014 +0300 @@ -14,7 +14,7 @@ &dict_unix_listeners_array[0] }; static buffer_t dict_unix_listeners_buf = { - dict_unix_listeners, sizeof(dict_unix_listeners), { 0, } + dict_unix_listeners, sizeof(dict_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/director/director-settings.c --- a/src/director/director-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/director/director-settings.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ }; static buffer_t director_unix_listeners_buf = { director_unix_listeners, - sizeof(director_unix_listeners), { 0, } + sizeof(director_unix_listeners), { NULL, } }; static struct file_listener_settings director_fifo_listeners_array[] = { { "login/proxy-notify", 0, "", "" } @@ -29,7 +29,7 @@ }; static buffer_t director_fifo_listeners_buf = { director_fifo_listeners, - sizeof(director_fifo_listeners), { 0, } + sizeof(director_fifo_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/dns/dns-client-settings.c --- a/src/dns/dns-client-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/dns/dns-client-settings.c Tue May 27 21:17:34 2014 +0300 @@ -15,7 +15,7 @@ &dns_client_unix_listeners_array[0] }; static buffer_t dns_client_unix_listeners_buf = { - dns_client_unix_listeners, sizeof(dns_client_unix_listeners), { 0, } + dns_client_unix_listeners, sizeof(dns_client_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/doveadm/doveadm-settings.c --- a/src/doveadm/doveadm-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/doveadm/doveadm-settings.c Tue May 27 21:17:34 2014 +0300 @@ -17,7 +17,7 @@ &doveadm_unix_listeners_array[0] }; static buffer_t doveadm_unix_listeners_buf = { - doveadm_unix_listeners, sizeof(doveadm_unix_listeners), { 0, } + doveadm_unix_listeners, sizeof(doveadm_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/imap-login/imap-login-settings.c --- a/src/imap-login/imap-login-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap-login/imap-login-settings.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ &imap_login_inet_listeners_array[1] }; static buffer_t imap_login_inet_listeners_buf = { - imap_login_inet_listeners, sizeof(imap_login_inet_listeners), { 0, } + imap_login_inet_listeners, sizeof(imap_login_inet_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/imap-urlauth/imap-urlauth-login-settings.c --- a/src/imap-urlauth/imap-urlauth-login-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap-urlauth/imap-urlauth-login-settings.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ }; static buffer_t imap_urlauth_login_unix_listeners_buf = { imap_urlauth_login_unix_listeners, - sizeof(imap_urlauth_login_unix_listeners), { 0, } + sizeof(imap_urlauth_login_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/imap-urlauth/imap-urlauth-settings.c --- a/src/imap-urlauth/imap-urlauth-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap-urlauth/imap-urlauth-settings.c Tue May 27 21:17:34 2014 +0300 @@ -18,7 +18,7 @@ &imap_urlauth_unix_listeners_array[0] }; static buffer_t imap_urlauth_unix_listeners_buf = { - imap_urlauth_unix_listeners, sizeof(imap_urlauth_unix_listeners), { 0, } + imap_urlauth_unix_listeners, sizeof(imap_urlauth_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/imap-urlauth/imap-urlauth-worker-settings.c --- a/src/imap-urlauth/imap-urlauth-worker-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker-settings.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ &imap_urlauth_worker_unix_listeners_array[0] }; static buffer_t imap_urlauth_worker_unix_listeners_buf = { - imap_urlauth_worker_unix_listeners, sizeof(imap_urlauth_worker_unix_listeners), { 0, } + imap_urlauth_worker_unix_listeners, sizeof(imap_urlauth_worker_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/imap/imap-settings.c --- a/src/imap/imap-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/imap-settings.c Tue May 27 21:17:34 2014 +0300 @@ -22,7 +22,7 @@ &imap_unix_listeners_array[0] }; static buffer_t imap_unix_listeners_buf = { - imap_unix_listeners, sizeof(imap_unix_listeners), { 0, } + imap_unix_listeners, sizeof(imap_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/indexer/indexer-settings.c --- a/src/indexer/indexer-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/indexer/indexer-settings.c Tue May 27 21:17:34 2014 +0300 @@ -17,7 +17,7 @@ &indexer_unix_listeners_array[0] }; static buffer_t indexer_unix_listeners_buf = { - indexer_unix_listeners, sizeof(indexer_unix_listeners), { 0, } + indexer_unix_listeners, sizeof(indexer_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/indexer/indexer-worker-settings.c --- a/src/indexer/indexer-worker-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/indexer/indexer-worker-settings.c Tue May 27 21:17:34 2014 +0300 @@ -15,7 +15,7 @@ &indexer_worker_unix_listeners_array[0] }; static buffer_t indexer_worker_unix_listeners_buf = { - indexer_worker_unix_listeners, sizeof(indexer_worker_unix_listeners), { 0, } + indexer_worker_unix_listeners, sizeof(indexer_worker_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/ipc/ipc-settings.c --- a/src/ipc/ipc-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/ipc/ipc-settings.c Tue May 27 21:17:34 2014 +0300 @@ -17,7 +17,7 @@ &ipc_unix_listeners_array[1] }; static buffer_t ipc_unix_listeners_buf = { - ipc_unix_listeners, sizeof(ipc_unix_listeners), { 0, } + ipc_unix_listeners, sizeof(ipc_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/lmtp/lmtp-settings.c --- a/src/lmtp/lmtp-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lmtp/lmtp-settings.c Tue May 27 21:17:34 2014 +0300 @@ -22,7 +22,7 @@ &lmtp_unix_listeners_array[0] }; static buffer_t lmtp_unix_listeners_buf = { - lmtp_unix_listeners, sizeof(lmtp_unix_listeners), { 0, } + lmtp_unix_listeners, sizeof(lmtp_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/log/log-settings.c --- a/src/log/log-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/log/log-settings.c Tue May 27 21:17:34 2014 +0300 @@ -16,7 +16,7 @@ }; static buffer_t log_unix_listeners_buf = { log_unix_listeners, - sizeof(log_unix_listeners), { 0, } + sizeof(log_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/pop3-login/pop3-login-settings.c --- a/src/pop3-login/pop3-login-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/pop3-login/pop3-login-settings.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ &pop3_login_inet_listeners_array[1] }; static buffer_t pop3_login_inet_listeners_buf = { - pop3_login_inet_listeners, sizeof(pop3_login_inet_listeners), { 0, } + pop3_login_inet_listeners, sizeof(pop3_login_inet_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/pop3/pop3-settings.c --- a/src/pop3/pop3-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/pop3/pop3-settings.c Tue May 27 21:17:34 2014 +0300 @@ -22,7 +22,7 @@ &pop3_unix_listeners_array[0] }; static buffer_t pop3_unix_listeners_buf = { - pop3_unix_listeners, sizeof(pop3_unix_listeners), { 0, } + pop3_unix_listeners, sizeof(pop3_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/replication/aggregator/aggregator-settings.c --- a/src/replication/aggregator/aggregator-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/replication/aggregator/aggregator-settings.c Tue May 27 21:17:34 2014 +0300 @@ -14,7 +14,7 @@ &aggregator_unix_listeners_array[0] }; static buffer_t aggregator_unix_listeners_buf = { - aggregator_unix_listeners, sizeof(aggregator_unix_listeners), { 0, } + aggregator_unix_listeners, sizeof(aggregator_unix_listeners), { NULL, } }; static struct file_listener_settings aggregator_fifo_listeners_array[] = { @@ -24,7 +24,7 @@ &aggregator_fifo_listeners_array[0] }; static buffer_t aggregator_fifo_listeners_buf = { - aggregator_fifo_listeners, sizeof(aggregator_fifo_listeners), { 0, } + aggregator_fifo_listeners, sizeof(aggregator_fifo_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/replication/replicator/replicator-settings.c --- a/src/replication/replicator/replicator-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/replication/replicator/replicator-settings.c Tue May 27 21:17:34 2014 +0300 @@ -16,7 +16,7 @@ &replicator_unix_listeners_array[1] }; static buffer_t replicator_unix_listeners_buf = { - replicator_unix_listeners, sizeof(replicator_unix_listeners), { 0, } + replicator_unix_listeners, sizeof(replicator_unix_listeners), { NULL, } }; /* */ diff -r 03870eea2857 -r f373df52082a src/ssl-params/ssl-params-settings.c --- a/src/ssl-params/ssl-params-settings.c Tue May 27 21:17:34 2014 +0300 +++ b/src/ssl-params/ssl-params-settings.c Tue May 27 21:17:34 2014 +0300 @@ -21,7 +21,7 @@ &ssl_params_unix_listeners_array[1] }; static buffer_t ssl_params_unix_listeners_buf = { - ssl_params_unix_listeners, sizeof(ssl_params_unix_listeners), { 0, } + ssl_params_unix_listeners, sizeof(ssl_params_unix_listeners), { NULL, } From dovecot at dovecot.org Tue May 27 18:19:09 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:09 +0000 Subject: dovecot-2.2: various - trivial NULL-related sparse cleanups Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/552cab8feb5f changeset: 17398:552cab8feb5f user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: various - trivial NULL-related sparse cleanups These zero-alikes are all pointers, so should explicitly be NULL. Signed-off-by: Phil Carmody diffstat: src/config/sysinfo-get.c | 4 ++-- src/director/user-directory.c | 2 +- src/doveadm/doveadm-mail.c | 2 +- src/imap/imap-sync.c | 2 +- src/lib-http/http-transfer-chunked.c | 2 +- src/lib-sql/driver-sqlite.c | 2 +- src/util/script-login.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diffs (89 lines): diff -r f373df52082a -r 552cab8feb5f src/config/sysinfo-get.c --- a/src/config/sysinfo-get.c Tue May 27 21:17:34 2014 +0300 +++ b/src/config/sysinfo-get.c Tue May 27 21:17:34 2014 +0300 @@ -36,11 +36,11 @@ if (!readfile(path, &data)) return FALSE; - for (p = t_strsplit(data, "\n"); *p != '\0'; p++) { + for (p = t_strsplit(data, "\n"); *p != NULL; p++) { if (strncmp(*p, "DISTRIB_DESCRIPTION=", 20) == 0) break; } - if (*p == '\0') + if (*p == NULL) return FALSE; str = t_strcut(*p + 20, '\n'); diff -r f373df52082a -r 552cab8feb5f src/director/user-directory.c --- a/src/director/user-directory.c Tue May 27 21:17:34 2014 +0300 +++ b/src/director/user-directory.c Tue May 27 21:17:34 2014 +0300 @@ -328,7 +328,7 @@ user = iter->pos; if (user == NULL) - return FALSE; + return NULL; iter->pos = user->next; return user; diff -r f373df52082a -r 552cab8feb5f src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Tue May 27 21:17:34 2014 +0300 +++ b/src/doveadm/doveadm-mail.c Tue May 27 21:17:34 2014 +0300 @@ -604,7 +604,7 @@ } } - return FALSE; + return NULL; } bool doveadm_mail_try_run(const char *cmd_name, int argc, char *argv[]) diff -r f373df52082a -r 552cab8feb5f src/imap/imap-sync.c --- a/src/imap/imap-sync.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/imap-sync.c Tue May 27 21:17:34 2014 +0300 @@ -229,7 +229,7 @@ ctx->sync_ctx = mailbox_sync_init(box, flags); ctx->t = mailbox_transaction_begin(box, 0); - ctx->mail = mail_alloc(ctx->t, MAIL_FETCH_FLAGS, 0); + ctx->mail = mail_alloc(ctx->t, MAIL_FETCH_FLAGS, NULL); ctx->messages_count = client->messages_count; i_array_init(&ctx->tmp_keywords, client->keywords.announce_count + 8); diff -r f373df52082a -r 552cab8feb5f src/lib-http/http-transfer-chunked.c --- a/src/lib-http/http-transfer-chunked.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/http-transfer-chunked.c Tue May 27 21:17:34 2014 +0300 @@ -437,7 +437,7 @@ /* NOTE: trailer is currently ignored */ /* FIXME: limit trailer size */ tcstream->header_parser = - http_header_parser_init(tcstream->istream.parent, 0, TRUE); + http_header_parser_init(tcstream->istream.parent, NULL, TRUE); } while ((ret=http_header_parse_next_field(tcstream->header_parser, diff -r f373df52082a -r 552cab8feb5f src/lib-sql/driver-sqlite.c --- a/src/lib-sql/driver-sqlite.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-sql/driver-sqlite.c Tue May 27 21:17:34 2014 +0300 @@ -133,7 +133,7 @@ if (driver_sqlite_connect(_db) < 0) return; - db->rc = sqlite3_exec(db->sqlite, query, NULL, 0, NULL); + db->rc = sqlite3_exec(db->sqlite, query, NULL, NULL, NULL); if (db->rc != SQLITE_OK) { i_error("sqlite: exec(%s) failed: %s (%d)", query, sqlite3_errmsg(db->sqlite), db->rc); diff -r f373df52082a -r 552cab8feb5f src/util/script-login.c --- a/src/util/script-login.c Tue May 27 21:17:34 2014 +0300 +++ b/src/util/script-login.c Tue May 27 21:17:34 2014 +0300 @@ -102,7 +102,7 @@ env_put(t_strconcat("IP=", net_ip2addr(&input.remote_ip), NULL)); env_put(t_strconcat("USER=", input.username, NULL)); - for (; args[i] != '\0'; i++) { + for (; args[i] != NULL; i++) { args[i] = str_tabunescape(t_strdup_noconst(args[i])); value = strchr(args[i], '='); if (value != NULL) { From dovecot at dovecot.org Tue May 27 18:19:14 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:14 +0000 Subject: dovecot-2.2: lib-http: trivial sparse cleanups - statics and exp... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d410e5ab6dd8 changeset: 17399:d410e5ab6dd8 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-http: trivial sparse cleanups - statics and explicit NULLs Signed-off-by: Phil Carmody diffstat: src/lib-http/test-http-date.c | 11 ++++++----- src/lib-http/test-http-header-parser.c | 18 +++++++++--------- src/lib-http/test-http-request-parser.c | 18 +++++++++--------- src/lib-http/test-http-response-parser.c | 8 ++++---- src/lib-http/test-http-server.c | 2 +- 5 files changed, 29 insertions(+), 28 deletions(-) diffs (253 lines): diff -r 552cab8feb5f -r d410e5ab6dd8 src/lib-http/test-http-date.c --- a/src/lib-http/test-http-date.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/test-http-date.c Tue May 27 21:17:34 2014 +0300 @@ -14,7 +14,7 @@ }; /* Valid date tests */ -struct http_date_test valid_date_tests[] = { +static const struct http_date_test valid_date_tests[] = { /* Preferred format: */ { .date_in = "Sun, 11 Nov 2007 09:42:43 GMT", @@ -105,7 +105,7 @@ } }; -unsigned int valid_date_test_count = N_ELEMENTS(valid_date_tests); +static const unsigned int valid_date_test_count = N_ELEMENTS(valid_date_tests); static void test_http_date_valid(void) { @@ -113,7 +113,8 @@ for (i = 0; i < valid_date_test_count; i++) T_BEGIN { const char *date_in, *date_out, *pdate_out; - struct tm *tm = &valid_date_tests[i].tm, ptm; + const struct tm *tm = &valid_date_tests[i].tm; + struct tm ptm; bool result; date_in = valid_date_tests[i].date_in; @@ -142,7 +143,7 @@ } /* Invalid date tests */ -const char *invalid_date_tests[] = { +static const char *invalid_date_tests[] = { "Mom, 09 Jul 2018 02:24:29 GMT", "Mon; 09 Jul 2018 02:24:29 GMT", "Mon, 09 Jul 2018 02:24:29 GMT", @@ -188,7 +189,7 @@ "Sun Nov 6 08:49:37 0000", }; -unsigned int invalid_date_test_count = N_ELEMENTS(invalid_date_tests); +static const unsigned int invalid_date_test_count = N_ELEMENTS(invalid_date_tests); static void test_http_date_invalid(void) { diff -r 552cab8feb5f -r d410e5ab6dd8 src/lib-http/test-http-header-parser.c --- a/src/lib-http/test-http-header-parser.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/test-http-header-parser.c Tue May 27 21:17:34 2014 +0300 @@ -22,7 +22,7 @@ /* Valid header tests */ -static struct http_header_parse_result valid_header_parse_result1[] = { +static const struct http_header_parse_result valid_header_parse_result1[] = { { "Date", "Sat, 06 Oct 2012 16:01:44 GMT" }, { "Server", "Apache/2.2.16 (Debian)" }, { "Last-Modified", "Mon, 30 Jul 2012 11:09:28 GMT" }, @@ -37,7 +37,7 @@ { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result2[] = { +static const struct http_header_parse_result valid_header_parse_result2[] = { { "Host", "p5-lrqzb4yavu4l7nagydw-428649-i2-v6exp3-ds.metric.example.com" }, { "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0)" }, { "Accept", "image/png,image/*;q=0.8,*/*;q=0.5" }, @@ -49,7 +49,7 @@ { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result3[] = { +static const struct http_header_parse_result valid_header_parse_result3[] = { { "Date", "Sat, 06 Oct 2012 17:12:37 GMT" }, { "Server", "Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze14 with" " Suhosin-Patch proxy_html/3.0.1 mod_python/3.3.1 Python/2.6.6" @@ -64,7 +64,7 @@ { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result4[] = { +static const struct http_header_parse_result valid_header_parse_result4[] = { { "Age", "58" }, { "Date", "Sun, 04 Aug 2013 09:33:09 GMT" }, { "Expires", "Sun, 04 Aug 2013 09:34:08 GMT" }, @@ -80,16 +80,16 @@ { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result5[] = { +static const struct http_header_parse_result valid_header_parse_result5[] = { { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result6[] = { +static const struct http_header_parse_result valid_header_parse_result6[] = { { "X-Frop", "This text\x80 contains obs-text\x81 characters" }, { NULL, NULL } }; -static struct http_header_parse_result valid_header_parse_result7[] = { +static const struct http_header_parse_result valid_header_parse_result7[] = { { "X-Frop", "This text contains invalid characters" }, { NULL, NULL } }; @@ -174,7 +174,7 @@ } }; -unsigned int valid_header_parse_test_count = N_ELEMENTS(valid_header_parse_tests); +static const unsigned int valid_header_parse_test_count = N_ELEMENTS(valid_header_parse_tests); static void test_http_header_parse_valid(void) { @@ -330,7 +330,7 @@ } }; -unsigned int invalid_header_parse_test_count = N_ELEMENTS(invalid_header_parse_tests); +static const unsigned int invalid_header_parse_test_count = N_ELEMENTS(invalid_header_parse_tests); static void test_http_header_parse_invalid(void) { diff -r 552cab8feb5f -r d410e5ab6dd8 src/lib-http/test-http-request-parser.c --- a/src/lib-http/test-http-request-parser.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/test-http-request-parser.c Tue May 27 21:17:34 2014 +0300 @@ -138,7 +138,7 @@ } }; -unsigned int valid_request_parse_test_count = +static const unsigned int valid_request_parse_test_count = N_ELEMENTS(valid_request_parse_tests); static const char * @@ -185,7 +185,7 @@ for (pos = 0; pos <= request_text_len && ret == 0; pos++) { test_istream_set_size(input, pos); ret = http_request_parse_next - (parser, FALSE, &request, &error_code, &error); + (parser, NULL, &request, &error_code, &error); } test_istream_set_size(input, request_text_len); while (ret > 0) { @@ -200,7 +200,7 @@ payload = NULL; } ret = http_request_parse_next - (parser, FALSE, &request, &error_code, &error); + (parser, NULL, &request, &error_code, &error); } test_out_reason("parse success", ret == 0, error); @@ -293,7 +293,7 @@ enum http_request_parse_error error_code; }; -static struct http_request_invalid_parse_test +static const struct http_request_invalid_parse_test invalid_request_parse_tests[] = { { .request = "GET: / HTTP/1.1\r\n" @@ -351,13 +351,13 @@ // FIXME: test request limits }; -static unsigned char invalid_request_with_nuls[] = +static const unsigned char invalid_request_with_nuls[] = "GET / HTTP/1.1\r\n" "Host: example.com\r\n" "Null: text\0server\r\n" "\r\n"; -unsigned int invalid_request_parse_test_count = +static unsigned int invalid_request_parse_test_count = N_ELEMENTS(invalid_request_parse_tests); static const char * @@ -406,7 +406,7 @@ test_begin(t_strdup_printf("http request invalid [%d]", i)); while ((ret=http_request_parse_next - (parser, FALSE, &request, &error_code, &error)) > 0); + (parser, NULL, &request, &error_code, &error)) > 0); test_out_reason("parse failure", ret < 0, error); if (ret < 0) { @@ -422,9 +422,9 @@ test_begin("http request with NULs"); input = i_stream_create_from_data(invalid_request_with_nuls, sizeof(invalid_request_with_nuls)-1); - parser = http_request_parser_init(input, 0); + parser = http_request_parser_init(input, NULL); while ((ret=http_request_parse_next - (parser, FALSE, &request, &error_code, &error)) > 0); + (parser, NULL, &request, &error_code, &error)) > 0); test_assert(ret < 0); test_end(); } diff -r 552cab8feb5f -r d410e5ab6dd8 src/lib-http/test-http-response-parser.c --- a/src/lib-http/test-http-response-parser.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/test-http-response-parser.c Tue May 27 21:17:34 2014 +0300 @@ -86,7 +86,7 @@ } }; -unsigned int valid_response_parse_test_count = +static const unsigned int valid_response_parse_test_count = N_ELEMENTS(valid_response_parse_tests); static void test_http_response_parse_valid(void) @@ -178,7 +178,7 @@ "Cache-Control: private\n\r" }; -unsigned int invalid_response_parse_test_count = +static const unsigned int invalid_response_parse_test_count = N_ELEMENTS(invalid_response_parse_tests); static void test_http_response_parse_invalid(void) @@ -212,7 +212,7 @@ * Bad response tests */ -static unsigned char bad_response_with_nuls[] = +static const unsigned char bad_response_with_nuls[] = "HTTP/1.1 200 OK\r\n" "Server: text\0server\r\n" "\r\n"; @@ -230,7 +230,7 @@ test_begin("http response with NULs"); input = i_stream_create_from_data(bad_response_with_nuls, sizeof(bad_response_with_nuls)-1); - parser = http_response_parser_init(input, 0); + parser = http_response_parser_init(input, NULL); while ((ret=http_response_parse_next(parser, FALSE, &response, &error)) > 0); test_out("parse success", ret == 0); header = http_response_header_get(&response, "server"); diff -r 552cab8feb5f -r d410e5ab6dd8 src/lib-http/test-http-server.c --- a/src/lib-http/test-http-server.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-http/test-http-server.c Tue May 27 21:17:34 2014 +0300 @@ -10,7 +10,7 @@ static struct connection_list *clients; static int fd_listen; -struct io *io_listen; +static struct io *io_listen; struct client { struct connection conn; From dovecot at dovecot.org Tue May 27 18:19:14 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:14 +0000 Subject: dovecot-2.2: lib-imap: tests - trivial static and const sparse c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a754433a208e changeset: 17400:a754433a208e user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-imap: tests - trivial static and const sparse cleanups Signed-off-by: Phil Carmody diffstat: src/lib-imap/test-imap-url.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diffs (77 lines): diff -r d410e5ab6dd8 -r a754433a208e src/lib-imap/test-imap-url.c --- a/src/lib-imap/test-imap-url.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-imap/test-imap-url.c Tue May 27 21:17:34 2014 +0300 @@ -14,7 +14,7 @@ }; /* Valid IMAP URL tests */ -struct valid_imap_url_test valid_url_tests[] = { +static const struct valid_imap_url_test valid_url_tests[] = { { .url = "imap://localhost", .url_parsed = { @@ -547,7 +547,7 @@ } }; -unsigned int valid_url_test_count = N_ELEMENTS(valid_url_tests); +static const unsigned int valid_url_test_count = N_ELEMENTS(valid_url_tests); static void test_imap_url_valid(void) { @@ -556,8 +556,8 @@ for (i = 0; i < valid_url_test_count; i++) T_BEGIN { const char *url = valid_url_tests[i].url; enum imap_url_parse_flags flags = valid_url_tests[i].flags; - struct imap_url *urlt = &valid_url_tests[i].url_parsed; - struct imap_url *urlb = &valid_url_tests[i].url_base; + const struct imap_url *urlt = &valid_url_tests[i].url_parsed; + const struct imap_url *urlb = &valid_url_tests[i].url_base; struct imap_url *urlp; const char *error = NULL; @@ -711,7 +711,7 @@ struct imap_url url_base; }; -struct invalid_imap_url_test invalid_url_tests[] = { +static const struct invalid_imap_url_test invalid_url_tests[] = { { .url = "http://www.dovecot.org" },{ @@ -872,7 +872,7 @@ }, }; -unsigned int invalid_url_test_count = N_ELEMENTS(invalid_url_tests); +static const unsigned int invalid_url_test_count = N_ELEMENTS(invalid_url_tests); static void test_imap_url_invalid(void) { @@ -881,7 +881,7 @@ for (i = 0; i < invalid_url_test_count; i++) T_BEGIN { const char *url = invalid_url_tests[i].url; enum imap_url_parse_flags flags = invalid_url_tests[i].flags; - struct imap_url *urlb = &invalid_url_tests[i].url_base; + const struct imap_url *urlb = &invalid_url_tests[i].url_base; struct imap_url *urlp; const char *error = NULL; @@ -899,7 +899,7 @@ } -const char *parse_create_url_tests[] = { +static const char *parse_create_url_tests[] = { "imap://host.example.com/", "imap://10.0.0.1/", #ifdef HAVE_IPV6 @@ -935,7 +935,7 @@ "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=user+user%3bname", }; -unsigned int parse_create_url_test_count = N_ELEMENTS(parse_create_url_tests); +static const unsigned int parse_create_url_test_count = N_ELEMENTS(parse_create_url_tests); static void test_imap_url_parse_create(void) { From dovecot at dovecot.org Tue May 27 18:19:14 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:14 +0000 Subject: dovecot-2.2: lib-mail: tests - trivial sparse cleanups Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/22f70e50c492 changeset: 17401:22f70e50c492 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-mail: tests - trivial sparse cleanups One static const, and one more obviously not-an-int integer. Signed-off-by: Phil Carmody diffstat: src/lib-mail/test-istream-qp-decoder.c | 1 + src/lib-mail/test-message-date.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diffs (23 lines): diff -r a754433a208e -r 22f70e50c492 src/lib-mail/test-istream-qp-decoder.c --- a/src/lib-mail/test-istream-qp-decoder.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-mail/test-istream-qp-decoder.c Tue May 27 21:17:34 2014 +0300 @@ -5,6 +5,7 @@ #include "istream-private.h" #include "istream-qp.h" +static const struct { const char *input; const char *output; diff -r a754433a208e -r 22f70e50c492 src/lib-mail/test-message-date.c --- a/src/lib-mail/test-message-date.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-mail/test-message-date.c Tue May 27 21:17:34 2014 +0300 @@ -32,7 +32,7 @@ { -2147483647, 0, TRUE }, #endif #if (TIME_T_MAX_BITS > 32 || !defined(TIME_T_SIGNED)) - { 4294967295, 0, TRUE }, + { 4294967295U, 0, TRUE }, #endif { 1194390440, 2*60, TRUE }, { 1194397640, 0, TRUE }, From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: various - 'static' sparse cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/48d651b2e82a changeset: 17402:48d651b2e82a user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: various - 'static' sparse cleanup Signed-off-by: Phil Carmody diffstat: src/anvil/anvil-connection.c | 2 +- src/config/config-connection.c | 2 +- src/indexer/indexer-client.c | 2 +- src/pop3-login/client-authenticate.c | 2 +- src/ssl-params/main.c | 2 +- src/stats/mail-stats.c | 2 +- src/stats/main.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diffs (84 lines): diff -r 22f70e50c492 -r 48d651b2e82a src/anvil/anvil-connection.c --- a/src/anvil/anvil-connection.c Tue May 27 21:17:34 2014 +0300 +++ b/src/anvil/anvil-connection.c Tue May 27 21:17:34 2014 +0300 @@ -32,7 +32,7 @@ unsigned int fifo:1; }; -struct anvil_connection *anvil_connections = NULL; +static struct anvil_connection *anvil_connections = NULL; static const char *const * anvil_connection_next_line(struct anvil_connection *conn) diff -r 22f70e50c492 -r 48d651b2e82a src/config/config-connection.c --- a/src/config/config-connection.c Tue May 27 21:17:34 2014 +0300 +++ b/src/config/config-connection.c Tue May 27 21:17:34 2014 +0300 @@ -32,7 +32,7 @@ unsigned int handshaked:1; }; -struct config_connection *config_connections = NULL; +static struct config_connection *config_connections = NULL; static const char *const * config_connection_next_line(struct config_connection *conn) diff -r 22f70e50c492 -r 48d651b2e82a src/indexer/indexer-client.c --- a/src/indexer/indexer-client.c Tue May 27 21:17:34 2014 +0300 +++ b/src/indexer/indexer-client.c Tue May 27 21:17:34 2014 +0300 @@ -38,7 +38,7 @@ unsigned int tag; }; -struct indexer_client *clients = NULL; +static struct indexer_client *clients = NULL; static unsigned int clients_count = 0; static void indexer_client_destroy(struct indexer_client *client); diff -r 22f70e50c492 -r 48d651b2e82a src/pop3-login/client-authenticate.c --- a/src/pop3-login/client-authenticate.c Tue May 27 21:17:34 2014 +0300 +++ b/src/pop3-login/client-authenticate.c Tue May 27 21:17:34 2014 +0300 @@ -19,7 +19,7 @@ #include -const char *capability_string = POP3_CAPABILITY_REPLY; +static const char *capability_string = POP3_CAPABILITY_REPLY; bool cmd_capa(struct pop3_client *client, const char *args ATTR_UNUSED) { diff -r 22f70e50c492 -r 48d651b2e82a src/ssl-params/main.c --- a/src/ssl-params/main.c Tue May 27 21:17:34 2014 +0300 +++ b/src/ssl-params/main.c Tue May 27 21:17:34 2014 +0300 @@ -21,7 +21,7 @@ }; static ARRAY(int) delayed_fds; -struct ssl_params *param; +static struct ssl_params *param; static buffer_t *ssl_params; static struct timeout *to_startup; diff -r 22f70e50c492 -r 48d651b2e82a src/stats/mail-stats.c --- a/src/stats/mail-stats.c Tue May 27 21:17:34 2014 +0300 +++ b/src/stats/mail-stats.c Tue May 27 21:17:34 2014 +0300 @@ -9,7 +9,7 @@ TYPE_TIMEVAL }; -struct mail_stats_parse_map { +static struct mail_stats_parse_map { const char *name; unsigned int offset; unsigned int size; diff -r 22f70e50c492 -r 48d651b2e82a src/stats/main.c --- a/src/stats/main.c Tue May 27 21:17:34 2014 +0300 +++ b/src/stats/main.c Tue May 27 21:17:34 2014 +0300 @@ -14,7 +14,7 @@ #include "mail-ip.h" #include "client.h" -struct stats_settings set; +static struct stats_settings set; static struct mail_server_connection *mail_server_conn = NULL; static void client_connected(struct master_service_connection *conn) From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: auth: sparse static cleanup, and some const cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c94d57a3aba3 changeset: 17403:c94d57a3aba3 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: auth: sparse static cleanup, and some const cleanup All the consts that are added to pointers represent deep const semantics. There are other shallow consts that I've not added, as sometimes it's better to not be const than have something you rely on change when you think it won't. Signed-off-by: Phil Carmody diffstat: src/auth/auth.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diffs (69 lines): diff -r 48d651b2e82a -r c94d57a3aba3 src/auth/auth.c --- a/src/auth/auth.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/auth.c Tue May 27 21:17:34 2014 +0300 @@ -9,7 +9,7 @@ #include "passdb.h" #include "auth.h" -struct auth_userdb_settings userdb_dummy_set = { +static const struct auth_userdb_settings userdb_dummy_set = { .name = "", .driver = "static", .args = "", @@ -110,9 +110,9 @@ auth_userdb->userdb = userdb_preinit(auth->pool, set); } -static bool auth_passdb_list_have_verify_plain(struct auth *auth) +static bool auth_passdb_list_have_verify_plain(const struct auth *auth) { - struct auth_passdb *passdb; + const struct auth_passdb *passdb; for (passdb = auth->masterdbs; passdb != NULL; passdb = passdb->next) { if (passdb->passdb->iface.verify_plain != NULL) @@ -125,9 +125,9 @@ return FALSE; } -static bool auth_passdb_list_have_lookup_credentials(struct auth *auth) +static bool auth_passdb_list_have_lookup_credentials(const struct auth *auth) { - struct auth_passdb *passdb; + const struct auth_passdb *passdb; for (passdb = auth->masterdbs; passdb != NULL; passdb = passdb->next) { if (passdb->passdb->iface.lookup_credentials != NULL) @@ -140,9 +140,9 @@ return FALSE; } -static int auth_passdb_list_have_set_credentials(struct auth *auth) +static int auth_passdb_list_have_set_credentials(const struct auth *auth) { - struct auth_passdb *passdb; + const struct auth_passdb *passdb; for (passdb = auth->masterdbs; passdb != NULL; passdb = passdb->next) { if (passdb->passdb->iface.set_credentials != NULL) @@ -156,7 +156,7 @@ } static bool -auth_mech_verify_passdb(struct auth *auth, struct mech_module_list *list) +auth_mech_verify_passdb(const struct auth *auth, const struct mech_module_list *list) { switch (list->module.passdb_need) { case MECH_PASSDB_NEED_NOTHING: @@ -180,9 +180,9 @@ return TRUE; } -static void auth_mech_list_verify_passdb(struct auth *auth) +static void auth_mech_list_verify_passdb(const struct auth *auth) { - struct mech_module_list *list; + const struct mech_module_list *list; for (list = auth->reg->modules; list != NULL; list = list->next) { if (!auth_mech_verify_passdb(auth, list)) From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: lib-imap: API change - add const to imap_url *base ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b37e71093468 changeset: 17404:b37e71093468 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-imap: API change - add const to imap_url *base parameter We do not change what's there, therefore we can promise to not change what is there. Signed-off-by: Phil Carmody diffstat: src/lib-imap/imap-url.c | 8 ++++---- src/lib-imap/imap-url.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diffs (51 lines): diff -r c94d57a3aba3 -r b37e71093468 src/lib-imap/imap-url.c --- a/src/lib-imap/imap-url.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-imap/imap-url.c Tue May 27 21:17:34 2014 +0300 @@ -119,7 +119,7 @@ enum imap_url_parse_flags flags; struct imap_url *url; - struct imap_url *base; + const struct imap_url *base; unsigned int relative:1; }; @@ -504,7 +504,7 @@ /* Resolve relative URI path; determine what to copy from the base URI */ if (url != NULL && url_parser->base != NULL && relative > 0) { - struct imap_url *base = url_parser->base; + const struct imap_url *base = url_parser->base; int rel = relative; /* /;PARTIAL= */ @@ -857,7 +857,7 @@ return FALSE; } else if (url_parser->url != NULL) { struct imap_url *url = url_parser->url; - struct imap_url *base = url_parser->base; + const struct imap_url *base = url_parser->base; url->host_name = p_strdup_empty(parser->pool, base->host_name); url->host_ip = base->host_ip; @@ -914,7 +914,7 @@ /* Public API */ -int imap_url_parse(const char *url, struct imap_url *base, +int imap_url_parse(const char *url, const struct imap_url *base, enum imap_url_parse_flags flags, struct imap_url **url_r, const char **error_r) { diff -r c94d57a3aba3 -r b37e71093468 src/lib-imap/imap-url.h --- a/src/lib-imap/imap-url.h Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-imap/imap-url.h Tue May 27 21:17:34 2014 +0300 @@ -56,7 +56,7 @@ }; /* Parses full IMAP URL. The returned URL is allocated from data stack. */ -int imap_url_parse(const char *url, struct imap_url *base, +int imap_url_parse(const char *url, const struct imap_url *base, enum imap_url_parse_flags flags, struct imap_url **url_r, const char **error_r); From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: imap: fix missing-command check Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9f1e53489674 changeset: 17405:9f1e53489674 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: imap: fix missing-command check It's impossible for the command's pointer to be NULL at this point. Previously, the command_find() would have returned NULL, but this check presumably short-circuits that search in the trivial case, so has some real use. Signed-off-by: Phil Carmody diffstat: src/imap/imap-client.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r b37e71093468 -r 9f1e53489674 src/imap/imap-client.c --- a/src/imap/imap-client.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/imap-client.c Tue May 27 21:17:34 2014 +0300 @@ -813,8 +813,8 @@ client->input_skip_line = TRUE; - if (cmd->name == '\0') { - /* command not given - cmd_func is already NULL. */ + if (cmd->name[0] == '\0') { + /* command not given - cmd->func is already NULL. */ } else if ((command = command_find(cmd->name)) != NULL) { cmd->func = command->func; cmd->cmd_flags = command->flags; From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: lib-otp: cast to the correct type of function pointer Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7cda826410f5 changeset: 17406:7cda826410f5 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: lib-otp: cast to the correct type of function pointer sparse complains about the result of the F() cast being the wrong type for the initialisation, which is true. So just cast to the right type in the first place. Signed-off-by: Phil Carmody diffstat: src/lib-otp/otp-hash.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diffs (30 lines): diff -r 9f1e53489674 -r 7cda826410f5 src/lib-otp/otp-hash.c --- a/src/lib-otp/otp-hash.c Tue May 27 21:17:34 2014 +0300 +++ b/src/lib-otp/otp-hash.c Tue May 27 21:17:34 2014 +0300 @@ -79,15 +79,21 @@ } -#define F(name) ((void (*)()) (name)) +#define F_INIT(name) ((void (*)(void *)) (name)) +#define F_UPDATE(name) ((void (*)(void *, const void *, size_t)) (name)) +#define F_FINAL(name) ((void (*)(void *, void *)) (name)) +#define F_FOLD(name) ((void (*)(void *, void *)) (name)) static const struct digest digests[] = { - { "md4", F(md4_init), F(md4_update), F(md4_final), F(md4_fold) }, - { "md5", F(md5_init), F(md5_update), F(md5_final), F(md5_fold) }, - { "sha1", F(sha1_init), F(sha1_loop), F(sha1_result), F(sha1_fold) }, + { "md4", F_INIT(md4_init), F_UPDATE(md4_update), F_FINAL(md4_final), F_FOLD(md4_fold) }, + { "md5", F_INIT(md5_init), F_UPDATE(md5_update), F_FINAL(md5_final), F_FOLD(md5_fold) }, + { "sha1", F_INIT(sha1_init), F_UPDATE(sha1_loop), F_FINAL(sha1_result), F_FOLD(sha1_fold) }, }; -#undef F +#undef F_INIT +#undef F_UPDATE +#undef F_FINAL +#undef F_FOLD const char *digest_name(unsigned int algo) { From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: auth: set_credentials callback being passed an enum... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/479d66a8e310 changeset: 17407:479d66a8e310 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: auth: set_credentials callback being passed an enum, not a bool This changes the behaviour, as the error case is now mapped onto FALSE. All non-zero values of course get squashed into true. Found by sparse. Signed-off-by: Phil Carmody diffstat: src/auth/auth-request.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 7cda826410f5 -r 479d66a8e310 src/auth/auth-request.c --- a/src/auth/auth-request.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/auth-request.c Tue May 27 21:17:34 2014 +0300 @@ -931,7 +931,7 @@ callback); } else { /* this passdb doesn't support credentials update */ - callback(PASSDB_RESULT_INTERNAL_FAILURE, request); + callback(FALSE, request); } } From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: auth: master-connection - bail on malformed list Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9207d1868963 changeset: 17408:9207d1868963 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: auth: master-connection - bail on malformed list If master is not communicating to us in a syntax we understand, just ask for it to be unplugged. This changes the behaviour in this error case. Previously, we returned -1, which is TRUE when converted to a boolean, and thus this changes the error semantics, and may be horribly wrong. However, the i_error()s in auth_master_input_line follow the same pattern. Signed-off-by: Phil Carmody diffstat: src/auth/auth-master-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 479d66a8e310 -r 9207d1868963 src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/auth-master-connection.c Tue May 27 21:17:34 2014 +0300 @@ -527,7 +527,7 @@ list = t_strsplit_tab(args); if (list[0] == NULL || str_to_uint(list[0], &id) < 0) { i_error("BUG: Master sent broken LIST"); - return -1; + return FALSE; } list++; From dovecot at dovecot.org Tue May 27 18:19:15 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:15 +0000 Subject: dovecot-2.2: indexer: fix indexer_queue_cancel_all behaviour Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4f90011e9823 changeset: 17409:4f90011e9823 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: indexer: fix indexer_queue_cancel_all behaviour -1 is TRUE. Presumably -1 was intended to be passed to the callbacks via indexer_queue_request_status_int(), not 100. Signed-off-by: Phil Carmody diffstat: src/indexer/indexer-queue.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9207d1868963 -r 4f90011e9823 src/indexer/indexer-queue.c --- a/src/indexer/indexer-queue.c Tue May 27 21:17:34 2014 +0300 +++ b/src/indexer/indexer-queue.c Tue May 27 21:17:34 2014 +0300 @@ -211,7 +211,7 @@ while ((request = indexer_queue_request_peek(queue)) != NULL) { indexer_queue_request_remove(queue); - indexer_queue_request_finish(queue, &request, -1); + indexer_queue_request_finish(queue, &request, FALSE); } } From dovecot at dovecot.org Tue May 27 18:19:16 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:16 +0000 Subject: dovecot-2.2: imap: cmd_getmetadata_stream_continue returns bool,... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c2da4daac0b8 changeset: 17410:c2da4daac0b8 user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: imap: cmd_getmetadata_stream_continue returns bool, not int The behaviour is unchanged, but we shouldn't pretend that -1 is different from TRUE in a boolean context. Its only caller only cares about whether it's 0 or not. Signed-off-by: Phil Carmody diffstat: src/imap/cmd-getmetadata.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 4f90011e9823 -r c2da4daac0b8 src/imap/cmd-getmetadata.c --- a/src/imap/cmd-getmetadata.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/cmd-getmetadata.c Tue May 27 21:17:34 2014 +0300 @@ -226,7 +226,7 @@ i_stream_get_error(ctx->cur_stream)); client_disconnect(ctx->cmd->client, "Internal GETMETADATA failure"); - return -1; + return TRUE; } if (!i_stream_have_bytes_left(ctx->cur_stream)) { /* Input stream gave less data than expected */ @@ -234,7 +234,7 @@ i_stream_get_name(ctx->cur_stream)); client_disconnect(ctx->cmd->client, "Internal GETMETADATA failure"); - return -1; + return TRUE; } o_stream_set_flush_pending(ctx->cmd->client->output, TRUE); return FALSE; From dovecot at dovecot.org Tue May 27 18:19:16 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:16 +0000 Subject: dovecot-2.2: imap: use human-readable helper macro in remote_ip_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/52ea7c8b587c changeset: 17411:52ea7c8b587c user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: imap: use human-readable helper macro in remote_ip_is_usable More readable, but helpfully shuts up sparse which complained about some constants being long. Signed-off-by: Phil Carmody diffstat: src/imap/cmd-idle.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (25 lines): diff -r c2da4daac0b8 -r 52ea7c8b587c src/imap/cmd-idle.c --- a/src/imap/cmd-idle.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/cmd-idle.c Tue May 27 21:17:34 2014 +0300 @@ -168,15 +168,17 @@ if (ip->family == 0) return FALSE; if (ip->family == AF_INET) { +#define IP4(a,b,c,d) ((unsigned)(a)<<24|(unsigned)(b)<<16|(unsigned)(c)<<8|(unsigned)(d)) addr = ip->u.ip4.s_addr; - if (addr >= 167772160 && addr <= 184549375) + if (addr >= IP4(10,0,0,0) && addr <= IP4(10,255,255,255)) return FALSE; /* 10/8 */ - if (addr >= 3232235520 && addr <= 3232301055) + if (addr >= IP4(192,168,0,0) && addr <= IP4(192,168,255,255)) return FALSE; /* 192.168/16 */ - if (addr >= 2886729728 && addr <= 2887778303) + if (addr >= IP4(172,16,0,0) && addr <= IP4(172,31,255,255)) return FALSE; /* 172.16/12 */ - if (addr >= 2130706432 && addr <= 2147483647) + if (addr >= IP4(127,0,0,0) && addr <= IP4(127,255,255,255)) return FALSE; /* 127/8 */ +#undef IP4 } #ifdef HAVE_IPV6 else if (ip->family == AF_INET6) { From dovecot at dovecot.org Tue May 27 18:19:21 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:21 +0000 Subject: dovecot-2.2: imap: exit imap_fetch_binary_init() identically on ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3f4d224f2e6a changeset: 17412:3f4d224f2e6a user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: imap: exit imap_fetch_binary_init() identically on all failures This changes the behaviour, as -1 is TRUE as a boolean. Signed-off-by: Phil Carmody diffstat: src/imap/imap-fetch-body.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 52ea7c8b587c -r 3f4d224f2e6a src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Tue May 27 21:17:34 2014 +0300 +++ b/src/imap/imap-fetch-body.c Tue May 27 21:17:34 2014 +0300 @@ -416,7 +416,7 @@ } if (imap_msgpart_parse(body->section, &body->msgpart) < 0) { ctx->error = "Invalid BINARY[..] section"; - return -1; + return FALSE; } imap_msgpart_set_decode_to_binary(body->msgpart); ctx->fetch_ctx->fetch_data |= From dovecot at dovecot.org Tue May 27 18:19:21 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 18:19:21 +0000 Subject: dovecot-2.2: auth: checkpassword callback callback type bike-she... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/51d44a72237c changeset: 17413:51d44a72237c user: Phil Carmody date: Tue May 27 21:17:34 2014 +0300 description: auth: checkpassword callback callback type bike-shedding This change doesn't change the compiler's (gcc) view on the correctness of the code. It moves sparse's attention of where the potential issues are though. Sparse used to complain about dodgy function pointer conversions on both the way out (passing the callback function pointer), and on the way in (entering the callback). Making the callback not lie about what it receives gets rid of the way in warnings, but adds warnings as we pass the new function pointer out. However, it already complains about that call anyway. So it complains about 6 things in 3 functions rather than 6 things in 6 functions. Of dubious worth, but it at least reduces the number of lines you need to inspect to verify correctness. Signed-off-by: Phil Carmody diffstat: src/auth/passdb-checkpassword.c | 6 ++---- src/auth/userdb-checkpassword.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diffs (39 lines): diff -r 3f4d224f2e6a -r 51d44a72237c src/auth/passdb-checkpassword.c --- a/src/auth/passdb-checkpassword.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/passdb-checkpassword.c Tue May 27 21:17:34 2014 +0300 @@ -17,9 +17,8 @@ auth_checkpassword_callback(struct auth_request *request, enum db_checkpassword_status status, const char *const *extra_fields, - void (*request_callback)()) + verify_plain_callback_t *callback) { - verify_plain_callback_t *callback = request_callback; const char *scheme, *crypted_pass = NULL; unsigned int i; @@ -71,9 +70,8 @@ credentials_checkpassword_callback(struct auth_request *request, enum db_checkpassword_status status, const char *const *extra_fields, - void (*request_callback)()) + lookup_credentials_callback_t *callback) { - lookup_credentials_callback_t *callback = request_callback; const char *scheme, *crypted_pass = NULL; unsigned int i; diff -r 3f4d224f2e6a -r 51d44a72237c src/auth/userdb-checkpassword.c --- a/src/auth/userdb-checkpassword.c Tue May 27 21:17:34 2014 +0300 +++ b/src/auth/userdb-checkpassword.c Tue May 27 21:17:34 2014 +0300 @@ -16,9 +16,8 @@ userdb_checkpassword_callback(struct auth_request *request, enum db_checkpassword_status status, const char *const *extra_fields, - void (*request_callback)()) + userdb_callback_t *callback) { - userdb_callback_t *callback = request_callback; unsigned int i; switch (status) { From dovecot at dovecot.org Tue May 27 20:12:07 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 May 2014 20:12:07 +0000 Subject: dovecot-2.2: Compiler warning fix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/30a0f18b60dc changeset: 17414:30a0f18b60dc user: Timo Sirainen date: Tue May 27 23:11:07 2014 +0300 description: Compiler warning fix diffstat: src/stats/main.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 51d44a72237c -r 30a0f18b60dc src/stats/main.c --- a/src/stats/main.c Tue May 27 21:17:34 2014 +0300 +++ b/src/stats/main.c Tue May 27 23:11:07 2014 +0300 @@ -14,7 +14,6 @@ #include "mail-ip.h" #include "client.h" -static struct stats_settings set; static struct mail_server_connection *mail_server_conn = NULL; static void client_connected(struct master_service_connection *conn) From dovecot at dovecot.org Wed May 28 01:21:56 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 28 May 2014 01:21:56 +0000 Subject: dovecot-2.2: lib-storage: "Message has no NUL characters" flag w... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0f618da2024b changeset: 17415:0f618da2024b user: Timo Sirainen date: Wed May 28 04:20:58 2014 +0300 description: lib-storage: "Message has no NUL characters" flag was being set wrong to cache file. Only the first MIME part was checked for its existence. When this flag was wrong, IMAP FETCH may have returned NUL characters instead of converting them to 0x80 character. This apparently caused Outlook to hang. diffstat: src/lib-storage/index/index-mail.c | 17 +++++++++++++++-- src/lib-storage/index/index-mail.h | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diffs (55 lines): diff -r 30a0f18b60dc -r 0f618da2024b src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Tue May 27 23:11:07 2014 +0300 +++ b/src/lib-storage/index/index-mail.c Wed May 28 04:20:58 2014 +0300 @@ -95,6 +95,19 @@ return parts; } +static bool message_parts_have_nuls(const struct message_part *part) +{ + for (; part != NULL; part = part->next) { + if ((part->flags & MESSAGE_PART_FLAG_HAS_NULS) != 0) + return TRUE; + if (part->children != NULL) { + if (message_parts_have_nuls(part->children)) + return TRUE; + } + } + return FALSE; +} + static bool get_cached_parts(struct index_mail *mail) { struct message_part *part; @@ -106,7 +119,7 @@ return FALSE; /* we know the NULs now, update them */ - if ((part->flags & MESSAGE_PART_FLAG_HAS_NULS) != 0) { + if (message_parts_have_nuls(part)) { mail->mail.mail.has_nuls = TRUE; mail->mail.mail.has_no_nuls = FALSE; } else { @@ -580,7 +593,7 @@ MAIL_CACHE_FLAG_BINARY_BODY | MAIL_CACHE_FLAG_HAS_NULS | MAIL_CACHE_FLAG_HAS_NO_NULS); - if ((data->parts->flags & MESSAGE_PART_FLAG_HAS_NULS) != 0) { + if (message_parts_have_nuls(data->parts)) { _mail->has_nuls = TRUE; _mail->has_no_nuls = FALSE; cache_flags |= MAIL_CACHE_FLAG_HAS_NULS; diff -r 30a0f18b60dc -r 0f618da2024b src/lib-storage/index/index-mail.h --- a/src/lib-storage/index/index-mail.h Tue May 27 23:11:07 2014 +0300 +++ b/src/lib-storage/index/index-mail.h Wed May 28 04:20:58 2014 +0300 @@ -43,7 +43,9 @@ /* Mail header or body is known to contain NUL characters. */ MAIL_CACHE_FLAG_HAS_NULS = 0x0004, /* Mail header or body is known to not contain NUL characters. */ - MAIL_CACHE_FLAG_HAS_NO_NULS = 0x0008, + MAIL_CACHE_FLAG_HAS_NO_NULS = 0x0020, + /* obsolete _HAS_NO_NULS flag, which was being set incorrectly */ + MAIL_CACHE_FLAG_HAS_NO_NULS_BROKEN = 0x0008, /* BODY is IMAP_BODY_PLAIN_7BIT_ASCII and rest of BODYSTRUCTURE fields are NIL */ From dovecot at dovecot.org Wed May 28 12:55:06 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 28 May 2014 12:55:06 +0000 Subject: dovecot-2.2: lib-index: Optimize removing large number of expunges. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6d2176c558af changeset: 17416:6d2176c558af user: Timo Sirainen date: Wed May 28 15:53:58 2014 +0300 description: lib-index: Optimize removing large number of expunges. diffstat: src/lib-index/mail-index-sync-update.c | 48 +++++++++++++++++++++------------ 1 files changed, 30 insertions(+), 18 deletions(-) diffs (96 lines): diff -r 0f618da2024b -r 6d2176c558af src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Wed May 28 04:20:58 2014 +0300 +++ b/src/lib-index/mail-index-sync-update.c Wed May 28 15:53:58 2014 +0300 @@ -231,16 +231,11 @@ } static void -sync_expunge(struct mail_index_sync_map_ctx *ctx, uint32_t uid1, uint32_t uid2) +sync_expunge(struct mail_index_sync_map_ctx *ctx, uint32_t seq1, uint32_t seq2) { struct mail_index_map *map; struct mail_index_record *rec; - uint32_t seq_count, seq, seq1, seq2; - - if (!mail_index_lookup_seq_range(ctx->view, uid1, uid2, &seq1, &seq2)) { - /* everything expunged already */ - return; - } + uint32_t seq_count, seq; sync_expunge_call_handlers(ctx, seq1, seq2); @@ -261,6 +256,18 @@ mail_index_modseq_expunge(ctx->modseq_ctx, seq1, seq2); } +static void +sync_expunge_range(struct mail_index_sync_map_ctx *ctx, const ARRAY_TYPE(seq_range) *seqs) +{ + const struct seq_range *range; + unsigned int i, count; + + /* do this in reverse so the memmove()s are smaller */ + range = array_get(seqs, &count); + for (i = count; i > 0; i--) + sync_expunge(ctx, range[i-1].seq1, range[i-1].seq2); +} + static void *sync_append_record(struct mail_index_map *map) { size_t append_pos; @@ -506,38 +513,43 @@ case MAIL_TRANSACTION_EXPUNGE: case MAIL_TRANSACTION_EXPUNGE|MAIL_TRANSACTION_EXPUNGE_PROT: { const struct mail_transaction_expunge *rec = data, *end; + ARRAY_TYPE(seq_range) seqs; + uint32_t seq1, seq2; if ((hdr->type & MAIL_TRANSACTION_EXTERNAL) == 0) { /* this is simply a request for expunge */ break; } + t_array_init(&seqs, 64); end = CONST_PTR_OFFSET(data, hdr->size); - for (; rec != end; rec++) - sync_expunge(ctx, rec->uid1, rec->uid2); + for (; rec != end; rec++) { + if (mail_index_lookup_seq_range(ctx->view, + rec->uid1, rec->uid2, &seq1, &seq2)) + seq_range_array_add_range(&seqs, seq1, seq2); + } + sync_expunge_range(ctx, &seqs); break; } case MAIL_TRANSACTION_EXPUNGE_GUID: case MAIL_TRANSACTION_EXPUNGE_GUID|MAIL_TRANSACTION_EXPUNGE_PROT: { const struct mail_transaction_expunge_guid *rec = data, *end; - ARRAY_TYPE(seq_range) uids; - const struct seq_range *range; - unsigned int i, count; + ARRAY_TYPE(seq_range) seqs; + uint32_t seq; if ((hdr->type & MAIL_TRANSACTION_EXTERNAL) == 0) { /* this is simply a request for expunge */ break; } - t_array_init(&uids, 64); + t_array_init(&seqs, 64); end = CONST_PTR_OFFSET(data, hdr->size); for (; rec != end; rec++) { i_assert(rec->uid != 0); - seq_range_array_add(&uids, rec->uid); + + if (mail_index_lookup_seq(ctx->view, rec->uid, &seq)) + seq_range_array_add(&seqs, seq); } - /* do this in reverse so the memmove()s are smaller */ - range = array_get(&uids, &count); - for (i = count; i > 0; i--) - sync_expunge(ctx, range[i-1].seq1, range[i-1].seq2); + sync_expunge_range(ctx, &seqs); break; } case MAIL_TRANSACTION_FLAG_UPDATE: { From dovecot at dovecot.org Wed May 28 15:18:57 2014 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 28 May 2014 15:18:57 +0000 Subject: dovecot-2.2: lib-index: Fixed somewhat random assert-crashes dur... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/de9b10f2e168 changeset: 17417:de9b10f2e168 user: Timo Sirainen date: Wed May 28 18:17:52 2014 +0300 description: lib-index: Fixed somewhat random assert-crashes during extension resizes. diffstat: src/lib-index/mail-index-transaction-export.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (17 lines): diff -r 6d2176c558af -r de9b10f2e168 src/lib-index/mail-index-transaction-export.c --- a/src/lib-index/mail-index-transaction-export.c Wed May 28 15:53:58 2014 +0300 +++ b/src/lib-index/mail-index-transaction-export.c Wed May 28 18:17:52 2014 +0300 @@ -114,10 +114,10 @@ /* we're resizing the extension. use the resize struct. */ intro = &resizes[ext_id]; - i_assert(intro->ext_id == idx || idx == (uint32_t)-1); - if (idx != (uint32_t)-1) + if (idx != (uint32_t)-1) { + intro->ext_id = idx; intro->name_size = 0; - else { + } else { intro->ext_id = (uint32_t)-1; intro->name_size = strlen(rext->name); }