summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-06-27 10:54:26 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-31 13:12:58 +0200
commita55db465eca2c4d9f0cb6f36640ee6a70634052d (patch)
treebf9e70c1361986bf192aa3c3cb9bd6a682ff6518 /methods
parenta5859f6e046686bdbad22b5266e756030c157f60 (diff)
methods/ftp: Cope with weird PASV responses
wu-ftpd sends the response without parens, whereas we expect them. I did not test the patch, but it should work. I added another return true if Pos is still npos after the second find to make sure we don't add npos to the string. Thanks: Lukasz Stelmach for the initial patch Closes: #420940 (cherry picked from commit 25a694165ae46c159e0d91bf0b27717f00dbc66e)
Diffstat (limited to 'methods')
-rw-r--r--methods/ftp.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc
index a8bc95938..edb758a81 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -498,12 +498,25 @@ bool FTPConn::GoPasv()
// Unsupported function
string::size_type Pos = Msg.find('(');
- if (Tag >= 400 || Pos == string::npos)
+ if (Tag >= 400)
+ return true;
+
+ //wu-2.6.2(1) ftp server, returns
+ //227 Entering Passive Mode 193,219,28,140,150,111
+ //without parentheses, let's try to cope with it.
+ //wget(1) and ftp(1) can.
+ if (Pos == string::npos)
+ Pos = Msg.rfind(' ');
+ else
+ ++Pos;
+
+ // Still unsupported function
+ if (Pos == string::npos)
return true;
// Scan it
unsigned a0,a1,a2,a3,p0,p1;
- if (sscanf(Msg.c_str() + Pos,"(%u,%u,%u,%u,%u,%u)",&a0,&a1,&a2,&a3,&p0,&p1) != 6)
+ if (sscanf(Msg.c_str() + Pos,"%u,%u,%u,%u,%u,%u",&a0,&a1,&a2,&a3,&p0,&p1) != 6)
return true;
/* Some evil servers return 0 to mean their addr. We can actually speak