aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-22 11:03:18 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-22 11:03:18 +0100
commit8ec6486d05c6bcefb688c095954b2b39881f0260 (patch)
treedfa9534450149818c15731dcf5273311706c28f9
parent59c1743c78eee777a5dbc7d7b430a586b6e49f12 (diff)
ftpserver.pl: Moved invalid RCPT TO: address detection to RCPT handler
Rather than detecting the TO address as missing in the DATA handler, moved the detection to the RCPT command handler where an error response can be generated.
-rwxr-xr-xtests/ftpserver.pl32
1 files changed, 15 insertions, 17 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 1c1512bf7..2120c8526 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -813,16 +813,26 @@ sub MAIL_smtp {
return 0;
}
-sub DATA_smtp {
- my $testno;
+sub RCPT_smtp {
+ my ($args) = @_;
- if($smtp_rcpt =~ /^TO:(.*)/) {
- $testno = $1;
+ logmsg "RCPT_smtp got $args\n";
+
+ if($args !~ /^TO:(.*)/) {
+ sendcontrol "501 Unrecognized parameter\r\n";
}
else {
- return; # failure
+ $smtp_rcpt = $1;
+
+ sendcontrol "200 Receivers accepted\r\n";
}
+ return 0;
+}
+
+sub DATA_smtp {
+ my $testno = $smtp_rcpt;
+
$testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
sendcontrol "354 Show me the mail\r\n";
@@ -885,18 +895,6 @@ sub DATA_smtp {
}
-sub RCPT_smtp {
- my ($args) = @_;
-
- logmsg "RCPT_smtp got $args\n";
-
- $smtp_rcpt = $args;
-
- sendcontrol "200 Receivers accepted\r\n";
-
- return 0;
-}
-
sub HELO_smtp {
my ($client) = @_;