From b0c3c1454a591ab56f8d4021721c4e7a6810e38c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Dec 2016 01:26:35 -0500 Subject: [PATCH] Break out of the connection loops if EOF is reached. --- pop3/conn.go | 5 ++++- smtp/conn.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pop3/conn.go b/pop3/conn.go index cbf86d3..6b5fe4c 100644 --- a/pop3/conn.go +++ b/pop3/conn.go @@ -54,8 +54,11 @@ func AcceptConnection(netConn net.Conn, po PostOffice, log zap.Logger) { for { conn.line, err = conn.tp.ReadLine() if err != nil { - conn.err("did't catch that") + if err == io.EOF { + break + } conn.log.Error("ReadLine()", zap.Error(err)) + conn.err("did't catch that") continue } diff --git a/smtp/conn.go b/smtp/conn.go index 08d14c6..075ca21 100644 --- a/smtp/conn.go +++ b/smtp/conn.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "crypto/tls" "fmt" + "io" "net" "net/mail" "net/textproto" @@ -61,6 +62,10 @@ func AcceptConnection(netConn net.Conn, server Server, log zap.Logger) error { for { conn.line, err = conn.tp.ReadLine() if err != nil { + if err == io.EOF { + break + } + conn.log.Error("ReadLine()", zap.Error(err)) conn.writeReply(500, "line too long") continue } -- 2.43.5