Skip to content

[BUG] Buffered reader desynchronization causes AUTHENTICATE hangs and IDLE/DONE handling #249

Description

@Aravinda-HWK

Steps to Reproduce

  1. Start the IMAP server.
  2. Connect using a real IMAP client (e.g., Thunderbird, Apple Mail) or a custom TCP client.
  3. Send pipelined or fast consecutive commands:

Case 1: AUTHENTICATE hang

A1 AUTHENTICATE PLAIN\r\n
\r\n

Send both lines quickly (in the same TCP packet or without delay).

  1. Observe that the server does not proceed with authentication and appears to block or timeout.

  2. Case 2: Command corruption

A1 AUTHENTICATE PLAIN\r\n
\r\n
A2 LIST "" "*"\r\n

  1. Observe that:
  • Either authentication fails unexpectedly, or
  • The next command (LIST) is partially consumed or corrupted.
  1. Case 3: IDLE DONE not detected

A2 IDLE\r\n
DONE\r\n

  1. Send both lines quickly.
  2. Observe that:
  • Server does not exit IDLE mode properly
  • Session appears stuck

Expected Behavior

  • The server should correctly process all client input regardless of TCP packet boundaries or pipelining.
  • AUTHENTICATE should:
    - Immediately read the continuation input () without blocking
  • Commands sent after AUTHENTICATE should remain intact and be processed correctly
  • IDLE should:
    - Detect DONE reliably and exit IDLE mode immediately

Actual Behavior

  • AUTHENTICATE may:
    - Block indefinitely waiting for input that has already been sent
  • AUTHENTICATE may:
    - Over-read and consume bytes belonging to the next command
  • Subsequent commands may:
    - Be partially missing or malformed
  • IDLE may:
    - Fail to detect DONE and remain stuck

Relevant Logs / Screenshots

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions