Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions imapserver/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ func (c *Conn) serve() {
}

func (c *Conn) readCommand(dec *imapwire.Decoder) error {
for {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think using a for loop is necessary, plus it won't behave well regarding the command read timeout. We can just return if we got a CRLF and leave it to the caller to invoke readCommand again.

if dec.EOF() {
return nil
}

if dec.ExpectCRLF() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Expect family of functions sets the error field in the decoder. Since not getting a CRLF is valid, we should use Decoder.CRLF instead.

continue
}
break
}

var tag, name string
if !dec.ExpectAtom(&tag) || !dec.ExpectSP() || !dec.ExpectAtom(&name) {
return fmt.Errorf("in command: %w", dec.Err())
Expand Down