From 0972964722c3d525e116609f32fdaded4a9f41b5 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Tue, 8 Aug 2017 09:12:53 +0100 Subject: [PATCH] mda-lmtp: Handle "<>" addresses Either the recipient or from addresses can be "<>" to indicate the null address. mda-lmtp does not handle that well, as it sends "<<>>" which is invalid. This patch fixes that by special-casing them, which is unfortunate but reasonably common. --- cmd/mda-lmtp/mda-lmtp.go | 7 +++++++ cmd/mda-lmtp/test_tcp_null.cmy | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 cmd/mda-lmtp/test_tcp_null.cmy diff --git a/cmd/mda-lmtp/mda-lmtp.go b/cmd/mda-lmtp/mda-lmtp.go index cee639a..f6ead8d 100644 --- a/cmd/mda-lmtp/mda-lmtp.go +++ b/cmd/mda-lmtp/mda-lmtp.go @@ -84,6 +84,13 @@ func main() { tempExit("Could not get hostname: %v", err) } + if *fromwhom == "<>" { + *fromwhom = "" + } + if *recipient == "<>" { + *recipient = "" + } + cmd(tc, 250, "LHLO %s", hostname) cmd(tc, 250, "MAIL FROM:<%s>", *fromwhom) cmd(tc, 250, "RCPT TO:<%s>", *recipient) diff --git a/cmd/mda-lmtp/test_tcp_null.cmy b/cmd/mda-lmtp/test_tcp_null.cmy new file mode 100644 index 0000000..cdd95c9 --- /dev/null +++ b/cmd/mda-lmtp/test_tcp_null.cmy @@ -0,0 +1,32 @@ + +nc tcp_listen localhost:14932 + +mda |= ./mda-lmtp --addr=localhost:14932 -f "<>" -d "<>" < .data + +nc -> 220 Hola desde expect + +nc <~ LHLO .* +nc -> 250-Bienvenido! +nc -> 250 Contame... + +nc <- MAIL FROM:<> +nc -> 250 Aja + +nc <- RCPT TO:<> +nc -> 250 Aja + +nc <- DATA +nc -> 354 Dale + +nc <- Subject: test +nc <- +nc <- This is a test. +nc <- . + +nc -> 250 Recibido + +nc <- QUIT +nc -> 221 Chauchas + +mda wait 0 +