mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
ftpserver.pl: arbitrary application data splitting among TCP packets [II]
Take in account that 'pingpong' server commands may arrive splitted among several sockfilt 'DATA' PDU's.
This commit is contained in:
parent
e99128a5c9
commit
5c0ad9581d
@ -1926,6 +1926,8 @@ while(1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $full = "";
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
my $i;
|
my $i;
|
||||||
|
|
||||||
@ -1957,34 +1959,38 @@ while(1) {
|
|||||||
|
|
||||||
ftpmsg $input;
|
ftpmsg $input;
|
||||||
|
|
||||||
|
$full .= $input;
|
||||||
|
|
||||||
|
# Loop until command completion
|
||||||
|
next unless($full =~ /\r\n$/);
|
||||||
|
|
||||||
# Remove trailing CRLF.
|
# Remove trailing CRLF.
|
||||||
$input =~ s/[\n\r]+$//;
|
$full =~ s/[\n\r]+$//;
|
||||||
|
|
||||||
my $FTPCMD;
|
my $FTPCMD;
|
||||||
my $FTPARG;
|
my $FTPARG;
|
||||||
my $full = $input;
|
|
||||||
if($proto eq "imap") {
|
if($proto eq "imap") {
|
||||||
# IMAP is different with its identifier first on the command line
|
# IMAP is different with its identifier first on the command line
|
||||||
unless(($input =~ /^([^ ]+) ([^ ]+) (.*)/) ||
|
unless(($full =~ /^([^ ]+) ([^ ]+) (.*)/) ||
|
||||||
($input =~ /^([^ ]+) ([^ ]+)/)) {
|
($full =~ /^([^ ]+) ([^ ]+)/)) {
|
||||||
sendcontrol "$1 '$input': command not understood.\r\n";
|
sendcontrol "$1 '$full': command not understood.\r\n";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
$cmdid=$1; # set the global variable
|
$cmdid=$1; # set the global variable
|
||||||
$FTPCMD=$2;
|
$FTPCMD=$2;
|
||||||
$FTPARG=$3;
|
$FTPARG=$3;
|
||||||
}
|
}
|
||||||
elsif($input =~ /^([A-Z]{3,4})(\s(.*))?$/i) {
|
elsif($full =~ /^([A-Z]{3,4})(\s(.*))?$/i) {
|
||||||
$FTPCMD=$1;
|
$FTPCMD=$1;
|
||||||
$FTPARG=$3;
|
$FTPARG=$3;
|
||||||
}
|
}
|
||||||
elsif(($proto eq "smtp") && ($input =~ /^[A-Z0-9+\/]{0,512}={0,2}$/i)) {
|
elsif(($proto eq "smtp") && ($full =~ /^[A-Z0-9+\/]{0,512}={0,2}$/i)) {
|
||||||
# SMTP long "commands" are base64 authentication data.
|
# SMTP long "commands" are base64 authentication data.
|
||||||
$FTPCMD=$input;
|
$FTPCMD=$full;
|
||||||
$FTPARG="";
|
$FTPARG="";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sendcontrol "500 '$input': command not understood.\r\n";
|
sendcontrol "500 '$full': command not understood.\r\n";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1994,6 +2000,8 @@ while(1) {
|
|||||||
print STDERR "IN: $full\n";
|
print STDERR "IN: $full\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$full = "";
|
||||||
|
|
||||||
my $delay = $delayreply{$FTPCMD};
|
my $delay = $delayreply{$FTPCMD};
|
||||||
if($delay) {
|
if($delay) {
|
||||||
# just go sleep this many seconds!
|
# just go sleep this many seconds!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user