From: Timo Sirainen Date: Wed, 21 Aug 2024 21:39:39 +0000 (+0300) Subject: imapc: Fix error message if attribute iteration fails X-Git-Tag: 2.4.0~422 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6aa3c6bd513ac60dfcb99f602bd66eadb0a15a0c;p=thirdparty%2Fdovecot%2Fcore.git imapc: Fix error message if attribute iteration fails 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. --- diff --git a/src/lib-storage/index/imapc/imapc-attribute.c b/src/lib-storage/index/imapc/imapc-attribute.c index 242d93a531..259a1102bb 100644 --- a/src/lib-storage/index/imapc/imapc-attribute.c +++ b/src/lib-storage/index/imapc/imapc-attribute.c @@ -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;