Skip to content

Commit

Permalink
fix: fail fast if IMAP FETCH cannot be parsed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
link2xt committed Nov 21, 2023
1 parent 30f8522 commit d1d3109
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/imap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d1d3109

Please sign in to comment.