gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 64/150: smtp: fix processing of initial dot in data


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 64/150: smtp: fix processing of initial dot in data
Date: Fri, 30 Mar 2018 16:48:38 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit 62cf2d180ed77bb977acf5d8b348d4431256638f
Author: Patrick Monnerat <address@hidden>
AuthorDate: Mon Feb 12 16:43:15 2018 +0100

    smtp: fix processing of initial dot in data
    
    RFC 5321 4.1.1.4 specifies the CRLF terminating the DATA command
    should be taken into account when chasing the <CRLF>.<CRLF> end marker.
    Thus a leading dot character in data is also subject to escaping.
    
    Tests 911 and test server are adapted to this situation.
    New tests 951 and 952 check proper handling of initial dot in data.
    
    Closes #2304
---
 lib/smtp.c                      |  5 +++++
 tests/data/Makefile.inc         |  2 +-
 tests/data/test911              |  1 -
 tests/data/{test911 => test951} | 16 +++++++---------
 tests/data/{test911 => test952} | 16 +++++++---------
 tests/ftpserver.pl              |  4 ++--
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/lib/smtp.c b/lib/smtp.c
index d9f1a854a..3f3b45a95 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -1289,6 +1289,11 @@ static CURLcode smtp_perform(struct connectdata *conn, 
bool *connected,
   /* Store the first recipient (or NULL if not specified) */
   smtp->rcpt = data->set.mail_rcpt;
 
+  /* Initial data character is the first character in line: it is implicitly
+     preceded by a virtual CRLF. */
+  smtp->trailing_crlf = TRUE;
+  smtp->eob = 2;
+
   /* Start the first command in the DO phase */
   if((data->set.upload || data->set.mimepost.kind) && data->set.mail_rcpt)
     /* MAIL transfer */
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 9635d12a1..31d299942 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -103,7 +103,7 @@ test909 test910 test911 test912 test913 test914 test915 
test916 test917 \
 test918 test919 test920 test921 test922 test923 test924 test925 test926 \
 test927 test928 test929 test930 test931 test932 test933 test934 test935 \
 test936 test937 test938 test939 test940 test941 test942 test943 test944 \
-test945 test946 test947 test948 test949 test950 \
+test945 test946 test947 test948 test949 test950 test951 test952 \
 \
 test1000 test1001 test1002 test1003 test1004 test1005 test1006 test1007 \
 test1008 test1009 test1010 test1011 test1012 test1013 test1014 test1015 \
diff --git a/tests/data/test911 b/tests/data/test911
index cc87349b8..f4c545830 100644
--- a/tests/data/test911
+++ b/tests/data/test911
@@ -40,7 +40,6 @@ DATA
 QUIT
 </protocol>
 <upload>
-
 .
 </upload>
 </verify>
diff --git a/tests/data/test911 b/tests/data/test951
similarity index 66%
copy from tests/data/test911
copy to tests/data/test951
index cc87349b8..7d2e17b1b 100644
--- a/tests/data/test911
+++ b/tests/data/test951
@@ -17,15 +17,13 @@ SMTP
 smtp
 </server>
  <name>
-SMTP with no mail data
+SMTP data with dot as first character
  </name>
-
-<stdin nonewline="yes">
-
+<stdin>
+.This first line starts with a dot
 </stdin>
-
- <command>
-smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt address@hidden --mail-from 
address@hidden -T -
+<command>
+smtp://%HOSTIP:%SMTPPORT/951 --mail-rcpt address@hidden --mail-from 
address@hidden -T -
 </command>
 </client>
 
@@ -33,14 +31,14 @@ smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt address@hidden 
--mail-from sende
 # Verify data after the test has been "shot"
 <verify>
 <protocol>
-EHLO 911
+EHLO 951
 MAIL FROM:<address@hidden>
 RCPT TO:<address@hidden>
 DATA
 QUIT
 </protocol>
 <upload>
-
+..This first line starts with a dot
 .
 </upload>
 </verify>
diff --git a/tests/data/test911 b/tests/data/test952
similarity index 74%
copy from tests/data/test911
copy to tests/data/test952
index cc87349b8..54334b21e 100644
--- a/tests/data/test911
+++ b/tests/data/test952
@@ -17,15 +17,13 @@ SMTP
 smtp
 </server>
  <name>
-SMTP with no mail data
+SMTP data with single dot-only line
  </name>
-
-<stdin nonewline="yes">
-
+<stdin>
+.
 </stdin>
-
- <command>
-smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt address@hidden --mail-from 
address@hidden -T -
+<command>
+smtp://%HOSTIP:%SMTPPORT/952 --mail-rcpt address@hidden --mail-from 
address@hidden -T -
 </command>
 </client>
 
@@ -33,14 +31,14 @@ smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt address@hidden 
--mail-from sende
 # Verify data after the test has been "shot"
 <verify>
 <protocol>
-EHLO 911
+EHLO 952
 MAIL FROM:<address@hidden>
 RCPT TO:<address@hidden>
 DATA
 QUIT
 </protocol>
 <upload>
-
+..
 .
 </upload>
 </verify>
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 956275881..f7f4fa2ae 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2014, 2017, Daniel Stenberg, <address@hidden>, et al.
+# Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -920,7 +920,7 @@ sub DATA_smtp {
                 print FILE $line if(!$nosave);
 
                 $raw .= $line;
-                if($raw =~ /\x0d\x0a\x2e\x0d\x0a/) {
+                if($raw =~ /(?:^|\x0d\x0a)\x2e\x0d\x0a/) {
                     # end of data marker!
                     $eob = 1;
                 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]