Errorhandling of "bad" FTP Servers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Errorhandling of "bad" FTP Servers

Oliver Zemann-2
Hi, i would like to know how to handle FTP Servers that do not behave
like they should (or behave different than most others).
For example, currently i would like to connect to one of those servers
which sends " MODE Z" directly after a login (USER) which is interpreted
wrong by apache commons ftp, as its assumed that there should be \d\d\d
\w* like "220 all good my friend"
But its simply: " MODE Z"

Here is a log from filezilla which can handle this behaviour:
09:58:24    Trace:    CFtpControlSocket::SendNextCommand()
09:58:24    Befehl:    USER someUser
09:58:24    Trace:    CFtpControlSocket::OnReceive()
09:58:24    Antwort:    331  ~wait~ user ok, password?
09:58:24    Trace:    CFtpControlSocket::SendNextCommand()
09:58:24    Befehl:    PASS *******
09:58:25    Trace:    CFtpControlSocket::OnReceive()
09:58:25    Antwort:    230 .::WAIT::. welcome!.
09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
09:58:25    Befehl:    SYST
09:58:25    Trace:    CFtpControlSocket::OnReceive()
09:58:25    Antwort:    215 Java (SE) Platform SE 6.0
09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
09:58:25    Befehl:    FEAT
09:58:25    Trace:    CFtpControlSocket::OnReceive()
09:58:25    Antwort:    211-Extension supported
09:58:25    Antwort:     MDTM
09:58:25    Antwort:     MDTM
09:58:25    Antwort:     MDTM YYYYMMDDHHMMSS[+-TZ];filename
09:58:25    Antwort:     SIZE
09:58:25    Antwort:     SITE PSWD;EXEC;SET;INDEX;ZONE;CHMOD;MSG
09:58:25    Antwort:     XCRC filename;start;end
09:58:25    Antwort:    211 End
09:58:25    Status:    Der Server unterst├╝tzt keine Nicht-ASCII-Zeichen.
09:58:25    Status:    Angemeldet
09:58:25    Antwort:     MODE Z
09:58:25    Trace:    Unexpected reply, no reply was pending. <----
something like this in apache commons ftp???
09:58:25    Antwort:    211 End
09:58:25    Trace:    Unexpected reply, no reply was pending.
09:58:25    Status:    Empfange Verzeichnisinhalt...
09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
09:58:25    Trace:    CFtpControlSocket::ChangeDirSend()
09:58:25    Befehl:    PWD
09:58:25    Trace:    CFtpControlSocket::OnReceive()
09:58:25    Antwort:    257 "/" <<<>>>OK<<<>>> Logged in ;).

That "MODE Z" is leading to an exception when i use FTPClient::login()
In __getReply(boolean reportReply)  i can see that its trying to convert
the first 3 chars to a digit, which is of course impossible if its "Z
MODE" and not a number.

So i am wondering whats the best way to handle such servers? Or is this
a bug in apache commons ftp? Do i have to implement all calls myself and
dont rely on login() logout() etc. from apache commons to be able to
handle such behaviours?

Some information: i dont have control over that server. I dont know what
software the server is running.

Regards
Oli

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]