From: Timo Sirainen Date: Wed, 10 Feb 2021 11:13:34 +0000 (+0200) Subject: imap: NOTIFY - Fix crash if client disconnects while sending FETCH notification X-Git-Tag: 2.3.15~376 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4f4058d16096f23eea0b3182205d6653f5954dd;p=thirdparty%2Fdovecot%2Fcore.git imap: NOTIFY - Fix crash if client disconnects while sending FETCH notification Fixes: Panic: Trying to close mailbox INBOX with open transactions --- diff --git a/src/imap/imap-notify.c b/src/imap/imap-notify.c index 481caad6e0..ca6303adc7 100644 --- a/src/imap/imap-notify.c +++ b/src/imap/imap-notify.c @@ -273,12 +273,12 @@ imap_client_notify_selected(struct client *client) if (!fetch_ctx->state.fetching) return 1; - if ((ret = imap_fetch_more_no_lock_update(fetch_ctx)) <= 0) - return ret; + if ((ret = imap_fetch_more_no_lock_update(fetch_ctx)) == 0) + return 0; /* finished the FETCH */ if (imap_fetch_end(fetch_ctx) < 0) return -1; - return 1; + return ret; } static int imap_client_notify_more(struct client *client) diff --git a/src/imap/imap-sync.c b/src/imap/imap-sync.c index 2a6b02d3a7..13b6101787 100644 --- a/src/imap/imap-sync.c +++ b/src/imap/imap-sync.c @@ -42,12 +42,12 @@ static int search_update_fetch_more(const struct imap_search_update *update) { int ret; - if ((ret = imap_fetch_more_no_lock_update(update->fetch_ctx)) <= 0) - return ret; + if ((ret = imap_fetch_more_no_lock_update(update->fetch_ctx)) == 0) + return 0; /* finished the FETCH */ if (imap_fetch_end(update->fetch_ctx) < 0) return -1; - return 1; + return ret; } static int