diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-09-29 09:25:23 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-09-29 09:25:23 +0100 |
commit | ab7e6afd44f1b447b8d6546ca351e858d2784ac5 (patch) | |
tree | feed0fb2cd31d4943dec8098fb967a2b4c151074 /tests/ftpserver.pl | |
parent | 4d7bf73fc31c724f8af9fb7eaf398fae7366e16f (diff) | |
download | curl-ab7e6afd44f1b447b8d6546ca351e858d2784ac5.tar.gz |
ftpserver.pl: Added unwanted argument check to SMTP DATA command handler
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-x | tests/ftpserver.pl | 102 |
1 files changed, 58 insertions, 44 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index be2d545ba..838d849a0 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -871,68 +871,81 @@ sub RCPT_smtp { } sub DATA_smtp { + my ($args) = @_; my $testno = $smtp_rcpt; - $testno =~ s/^([^0-9]*)([0-9]+).*/$2/; - sendcontrol "354 Show me the mail\r\n"; + if ($args) { + sendcontrol "501 Unrecognized parameter\r\n"; + } + else { + $testno =~ s/^([^0-9]*)([0-9]+).*/$2/; + sendcontrol "354 Show me the mail\r\n"; - logmsg "===> rcpt $testno was $smtp_rcpt\n"; + logmsg "===> rcpt $testno was $smtp_rcpt\n"; - my $filename = "log/upload.$testno"; + my $filename = "log/upload.$testno"; - logmsg "Store test number $testno in $filename\n"; + logmsg "Store test number $testno in $filename\n"; - open(FILE, ">$filename") || - return 0; # failed to open output + open(FILE, ">$filename") || + return 0; # failed to open output - my $line; - my $ulsize=0; - my $disc=0; - my $raw; - while (5 == (sysread \*SFREAD, $line, 5)) { - if($line eq "DATA\n") { - my $i; - my $eob; - sysread \*SFREAD, $i, 5; + my $line; + my $ulsize=0; + my $disc=0; + my $raw; + while (5 == (sysread \*SFREAD, $line, 5)) { + if($line eq "DATA\n") { + my $i; + my $eob; + sysread \*SFREAD, $i, 5; - my $size = 0; - if($i =~ /^([0-9a-fA-F]{4})\n/) { - $size = hex($1); - } + my $size = 0; + if($i =~ /^([0-9a-fA-F]{4})\n/) { + $size = hex($1); + } - read_mainsockf(\$line, $size); + read_mainsockf(\$line, $size); - $ulsize += $size; - print FILE $line if(!$nosave); + $ulsize += $size; + print FILE $line if(!$nosave); + + $raw .= $line; + if($raw =~ /\x0d\x0a\x2e\x0d\x0a/) { + # end of data marker! + $eob = 1; + } + + logmsg "> Appending $size bytes to file\n"; - $raw .= $line; - if($raw =~ /\x0d\x0a\x2e\x0d\x0a/) { - # end of data marker! - $eob = 1; + if($eob) { + logmsg "Found SMTP EOB marker\n"; + last; + } } - logmsg "> Appending $size bytes to file\n"; - if($eob) { - logmsg "Found SMTP EOB marker\n"; + elsif($line eq "DISC\n") { + # disconnect! + $disc=1; + last; + } + else { + logmsg "No support for: $line"; last; } } - elsif($line eq "DISC\n") { - # disconnect! - $disc=1; - last; - } - else { - logmsg "No support for: $line"; - last; + + if($nosave) { + print FILE "$ulsize bytes would've been stored here\n"; } + + close(FILE); + + logmsg "received $ulsize bytes upload\n"; + + sendcontrol "250 OK, data received!\r\n"; } - if($nosave) { - print FILE "$ulsize bytes would've been stored here\n"; - } - close(FILE); - sendcontrol "250 OK, data received!\r\n"; - logmsg "received $ulsize bytes upload\n"; + return 0; } sub QUIT_smtp { @@ -1163,6 +1176,7 @@ sub APPEND_imap { if($nosave) { print FILE "$size bytes would've been stored here\n"; } + close(FILE); logmsg "received $size bytes upload\n"; |