From d1d31096e09f364b218d760db5277a006d393fb5 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 21 Nov 2023 18:44:52 +0000 Subject: [PATCH] fix: fail fast if IMAP FETCH cannot be parsed Otherwise when connection is lost IMAP may get into infinite loop trying to parse remaining bytes: 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. 11-21 18:00:48.442 14858 12946 W DeltaChat: src/imap.rs:1457: Failed to process IMAP FETCH result: io: bytes remaining in stream. Returning an error bubbles it up to `fetch_idle()` which will call `trigger_reconnect()` and drop the connection. --- src/imap.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/imap.rs b/src/imap.rs index d1a7287889..fb5c3e9433 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1451,13 +1451,8 @@ impl Imap { break; }; - let next_fetch_response = match next_fetch_response { - Ok(next_fetch_response) => next_fetch_response, - Err(err) => { - warn!(context, "Failed to process IMAP FETCH result: {}.", err); - continue; - } - }; + let next_fetch_response = + next_fetch_response.context("Failed to process IMAP FETCH result")?; if let Some(next_uid) = next_fetch_response.uid { if next_uid == request_uid {