]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual: Avoid assert-crash if backend mailbox's have_guid lookup fails
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 6 Jul 2017 08:24:35 +0000 (11:24 +0300)
committerGitLab <gitlab@git.dovecot.net>
Thu, 6 Jul 2017 08:52:56 +0000 (11:52 +0300)
The MAIL_ERROR_NOTFOUND can happen if the mailbox was already deleted.
Other errors aren't expected to happen and possibly point to a bug.

Fixes:
Panic: file mail-storage.c: line 1831: unreached

src/plugins/virtual/virtual-storage.c

index 32b89ba7de541e324afab5f944da6c70e86ef6ec..2066ea81bed7f3c1dd9c156641b76b64b62fade5 100644 (file)
@@ -554,8 +554,23 @@ static int virtual_storage_set_have_guid_flags(struct virtual_mailbox *mbox)
        bboxes = array_get(&mbox->backend_boxes, &count);
        for (i = 0; i < count; i++) {
                if (mailbox_get_status(bboxes[i]->box, 0, &status) < 0) {
-                       virtual_box_copy_error(&mbox->box, bboxes[i]->box);
-                       return -1;
+                       const char *errstr;
+                       enum mail_error error;
+
+                       errstr = mailbox_get_last_error(bboxes[i]->box, &error);
+                       if (error == MAIL_ERROR_NOTFOUND) {
+                               /* backend mailbox was just lost - skip it */
+                               continue;
+                       }
+                       /* Not expected to happen, but we can't return failure
+                          since this could be called from
+                          mailbox_get_open_status() and it would panic.
+                          So just log the error and skip the mailbox. */
+                       mail_storage_set_critical(mbox->box.storage,
+                               "Virtual mailbox %s: Failed to get have_guid existence for backend mailbox %s: %s",
+                               mailbox_get_vname(&mbox->box),
+                               mailbox_get_vname(bboxes[i]->box), errstr);
+                       continue;
                }
                if (!status.have_guids)
                        mbox->have_guids = FALSE;