git » chasquid » commit 0972964

mda-lmtp: Handle "<>" addresses

author Alberto Bertogli
2017-08-08 08:12:53 UTC
committer Alberto Bertogli
2017-08-08 08:12:53 UTC
parent 6867859d5c35d0cc95f94e91b48d954e62a07c74

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 -0
cmd/mda-lmtp/test_tcp_null.cmy +32 -0

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
+