Lmtp2nntp - patch regarding parsing of "RCPT TO"

From Perswiki
Jump to: navigation, search

A very minor, but essential patch to lmtp2nntp 1.4.1.

2016/03/22 I have also sent it to the author at ossp.org, but my email bounced.

Summary: when the MTA hands over something to lmtp2nntp, the RCPT TO line may contain more than one token. For instance, it might look like this:

RCPT TO: <recipient@example.com>  ORCPT=<another@example.com>;

The patch below amends the regex pattern to only look at the first token and ignore any subsequent ones.

diff -ur a/lmtp2nntp_main.c b/lmtp2nntp_main.c
--- a/lmtp2nntp_main.c  2004-05-07 16:52:03.000000000 +0200
+++ b/lmtp2nntp_main.c  2016-03-22 11:29:34.397744519 +0100
@@ -1315,7 +1315,7 @@
      *  RFC1893 3.5 Network and Routing Status          X.5.2   Syntax error
      */
     logbook(ctx->l2, L2_LEVEL_TRACE, "checking parameter syntax");
-    if (str_parse(req->msg, "m/^RCPT To:\\s*(.+)$/i", &cp) <= 0) {
+    if (str_parse(req->msg, "m/^RCPT To:\\s*(<[^>]+>)/i", &cp) <= 0) {
         res.statuscode = "501";
         res.dsncode    = "5.5.2";
         res.statusmsg  = "Syntax error in parameters.";