]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fix error message if attribute iteration fails
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 21 Aug 2024 21:39:39 +0000 (00:39 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:59 +0000 (10:39 +0200)
The error message was set to storage in iteration init, but it wasn't
looked up until at iteration deinit. Normally this wouldn't have been
a problem, except the generic attribute iteration code didn't know
about this failure at init time yet, so it added extra attributes
which were returned. Handling these extra attributes could have caused
other errors, which replaced the original error.

src/lib-storage/index/imapc/imapc-attribute.c

index 242d93a531cc6e34e27eb831662cd40b87645a7f..259a1102bb953326020bbe89a2c0ff7bae2976f7 100644 (file)
@@ -314,12 +314,15 @@ imapc_storage_attribute_iter_init(struct mailbox *box,
        case HANDLE_IMAPC:
                if (imapc_storage_attribute_cmd(box, GETMETADATA, type_flags,
                                                DEPTH_INFINITY, prefix, NULL,
-                                               iter->actx) < 0)
+                                               iter->actx) < 0) {
+                       mail_storage_last_error_push(box->storage);
                        iter->failed = TRUE;
+               }
                break;
        case HANDLE_UNAVAILABLE:
                break;
        default:
+               mail_storage_last_error_push(box->storage);
                iter->failed = TRUE;
                break;
        }
@@ -361,8 +364,12 @@ int imapc_storage_attribute_iter_deinit(struct mailbox_attribute_iter *_iter)
        int ret;
        if (iter->ictx != NULL)
                ret = index_storage_attribute_iter_deinit(iter->ictx);
-       else
-               ret = iter->failed ? -1 : 0;
+       else if (!iter->failed)
+               ret = 0;
+       else {
+               mail_storage_last_error_pop(iter->iter.box->storage);
+               ret = -1;
+       }
 
        imapc_storage_attribute_iter_destroy(&iter);
        return ret;