From 2d62a3bc7f17708610579cffe7a96e3797d0e125 Mon Sep 17 00:00:00 2001 From: cathugger Date: Sat, 8 Dec 2018 19:44:05 +0000 Subject: [PATCH] srnd: error while reading message isn't valid thing --- contrib/backends/srndv2/src/srnd/store.go | 8 ++++---- contrib/backends/srndv2/src/srnd/util.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/store.go b/contrib/backends/srndv2/src/srnd/store.go index d421e6c..b205a2d 100644 --- a/contrib/backends/srndv2/src/srnd/store.go +++ b/contrib/backends/srndv2/src/srnd/store.go @@ -547,8 +547,8 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter if e != nil { log.Println("failed to read entire message", e) } - pw_in.Close() - pr_in.Close() + pw_in.CloseWithError(e) + pr_in.CloseWithError(e) }() r := bufio.NewReader(pr_out) m, e := readMIMEHeader(r) @@ -579,7 +579,7 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter return } writeMIMEHeader(wr, m.Header) - read_message_body(m.Body, m.Header, self, wr, false, process) + err = read_message_body(m.Body, m.Header, self, wr, false, process) } return } @@ -632,7 +632,7 @@ func read_message_body(body io.Reader, hdr map[string][]string, store ArticleSto body = io.TeeReader(body, wr) } boundary, ok := params["boundary"] - if ok || content_type == "multipart/mixed" { + if content_type == "multipart/mixed" && ok { partReader := multipart.NewReader(body, boundary) for { part, err := partReader.NextPart() diff --git a/contrib/backends/srndv2/src/srnd/util.go b/contrib/backends/srndv2/src/srnd/util.go index efa9428..70db80d 100644 --- a/contrib/backends/srndv2/src/srnd/util.go +++ b/contrib/backends/srndv2/src/srnd/util.go @@ -801,8 +801,8 @@ func storeMessage(daemon *NNTPDaemon, hdr textproto.MIMEHeader, body io.Reader) go func() { var buff [65536]byte writeMIMEHeader(pw, hdr) - io.CopyBuffer(pw, body, buff[:]) - pw.Close() + _, e := io.CopyBuffer(pw, body, buff[:]) + pw.CloseWithError(e) }() err = daemon.store.ProcessMessage(f, pr, daemon.CheckText, hdr.Get("Newsgroups")) pr.Close()