aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Polański <michal@polanski.me>2020-11-27 19:33:34 +0100
committerAndy Postnikov <apostnikov@gmail.com>2020-11-27 20:14:40 +0000
commita8f80f0c1f8a2b3d6c80fe6038392e6b79d17853 (patch)
tree657009bd8a865b05cfe174c6b06db3fadc24fb85
parent028517963f98da970cb2dc3c07b70e946b4ddea7 (diff)
downloadaports-a8f80f0c1f8a2b3d6c80fe6038392e6b79d17853.tar.gz
aports-a8f80f0c1f8a2b3d6c80fe6038392e6b79d17853.tar.bz2
aports-a8f80f0c1f8a2b3d6c80fe6038392e6b79d17853.tar.xz
testing/maddy: fix autobuffer function
-rw-r--r--testing/maddy/APKBUILD6
-rw-r--r--testing/maddy/fix-autobuffer-function.patch68
2 files changed, 72 insertions, 2 deletions
diff --git a/testing/maddy/APKBUILD b/testing/maddy/APKBUILD
index 451f43beda..0cd261656b 100644
--- a/testing/maddy/APKBUILD
+++ b/testing/maddy/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=maddy
pkgver=0.4.2
-pkgrel=0
+pkgrel=1
pkgdesc="Composable all-in-one mail server"
url="https://foxcpp.dev/maddy/"
license="GPL-3.0-or-later"
@@ -17,6 +17,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/foxcpp/maddy/archive/v$pkgve
$pkgname.initd
$pkgname.confd
use-syslog.patch
+ fix-autobuffer-function.patch
"
export GOPATH="$srcdir"
@@ -70,4 +71,5 @@ vim() {
sha512sums="05ba01f56b50614fcb9ca2ff9d41dbc034053a4ec77995c53f81fb3f992c1412c7a6621dfd8bdbf091751e70461f5021342c99ebad2092c726a32460960217a7 maddy-0.4.2.tar.gz
1c5c1d98e9a734bb3da60691f6d94005ea63cfb2de882c152211b1e8f4860556dabcdca4f160c8e612e7ec488d2c37e314c376e5bc9d5283cf47161958f4525b maddy.initd
0d7cc93c87b6b8ada3ee929513ae98f9393497371caaad85381f78f4a9ee7ec6523192fbea82ada013a7999521c0b88d6ca6a53a374b7b54f4a8e3d23cdda421 maddy.confd
-aab47869dd3b1e51fa0468fba8dcd24e2930127017b147165db280e28fb183f42b0401e8fcfa6dfb717c82fcecb4584934ddf3d73ad9f46034e0bd939bb96075 use-syslog.patch"
+aab47869dd3b1e51fa0468fba8dcd24e2930127017b147165db280e28fb183f42b0401e8fcfa6dfb717c82fcecb4584934ddf3d73ad9f46034e0bd939bb96075 use-syslog.patch
+3a72776be83f3a3f03d2655222a031ed61dacdbf44f139ee545e81d7e7079c4050de17ee3c69aa351da74d849ceb61e7c3f80deffe88cc811836fda4c819e7f4 fix-autobuffer-function.patch"
diff --git a/testing/maddy/fix-autobuffer-function.patch b/testing/maddy/fix-autobuffer-function.patch
new file mode 100644
index 0000000000..eac867f989
--- /dev/null
+++ b/testing/maddy/fix-autobuffer-function.patch
@@ -0,0 +1,68 @@
+From 925b758e094335807f1928b59d1ceffac82b8a7a Mon Sep 17 00:00:00 2001
+From: "fox.cpp" <fox.cpp@disroot.org>
+Date: Fri, 27 Nov 2020 21:04:17 +0300
+Subject: [PATCH] endpoint/smtp: Actually fix autobuffer function
+
+Regressed in 1c42a705334b3d34b4b3ddff74c654773a4c0ef5.
+It truncates messages to I/O buffer size (4096 bytes).
+If first 4096 bytes cover head then it causes "unexpected EOF" (see
+ #300), otherwise it silently breaks the message.
+---
+ internal/endpoint/smtp/session.go | 4 ++--
+ internal/endpoint/smtp/smtp.go | 12 ++++++++----
+ 2 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/internal/endpoint/smtp/session.go b/internal/endpoint/smtp/session.go
+index ef32290..d27330e 100644
+--- a/internal/endpoint/smtp/session.go
++++ b/internal/endpoint/smtp/session.go
+@@ -336,7 +336,7 @@ func (s *Session) prepareBody(ctx context.Context, r io.Reader) (textproto.Heade
+ bufr := bufio.NewReader(r)
+ header, err := textproto.ReadHeader(bufr)
+ if err != nil {
+- return textproto.Header{}, nil, err
++ return textproto.Header{}, nil, fmt.Errorf("I/O error while parsing header: %w", err)
+ }
+
+ if s.endp.submission {
+@@ -348,7 +348,7 @@ func (s *Session) prepareBody(ctx context.Context, r io.Reader) (textproto.Heade
+
+ buf, err := s.endp.buffer(bufr)
+ if err != nil {
+- return textproto.Header{}, nil, err
++ return textproto.Header{}, nil, fmt.Errorf("I/O error while writing buffer: %w", err)
+ }
+
+ return header, buf, nil
+diff --git a/internal/endpoint/smtp/smtp.go b/internal/endpoint/smtp/smtp.go
+index 1d57f9f..ebed9b0 100644
+--- a/internal/endpoint/smtp/smtp.go
++++ b/internal/endpoint/smtp/smtp.go
+@@ -149,19 +149,23 @@ func autoBufferMode(maxSize int, dir string) func(io.Reader) (buffer.Buffer, err
+ return func(r io.Reader) (buffer.Buffer, error) {
+ // First try to read up to N bytes.
+ initial := make([]byte, maxSize)
+- actualSize, err := r.Read(initial)
++ actualSize, err := io.ReadFull(r, initial)
+ if err != nil {
+- if err == io.EOF {
+- log.Debugln("autobuffer: keeping the message in RAM")
++ if err == io.ErrUnexpectedEOF {
++ log.Debugln("autobuffer: keeping the message in RAM (read", actualSize, "bytes, got EOF)")
+ return buffer.MemoryBuffer{Slice: initial[:actualSize]}, nil
+ }
++ if err == io.EOF {
++ // Special case: message with empty body.
++ return buffer.MemoryBuffer{}, nil
++ }
+ // Some I/O error happened, bail out.
+ return nil, err
+ }
+ if actualSize < maxSize {
+ // Ok, the message is smaller than N. Make a MemoryBuffer and
+ // handle it in RAM.
+- log.Debugln("autobuffer: keeping the message in RAM")
++ log.Debugln("autobuffer: keeping the message in RAM (read", actualSize, "bytes, got short read)")
+ return buffer.MemoryBuffer{Slice: initial[:actualSize]}, nil
+ }
+