Hi,

We have been using ftp.proxy for some time now, but recently I found
that I could not get access to a particular site. I upgraded to the
latest version (1.1.5), but still no joy. On further investigation I
found this to be caused by the server greeting being issued by the site.
Here is the greeting:

        220-Serv-U FTP Server v4.0 for WinSock ready...
        220-
        220-If you receive a "home directory does not exist" error,
        220-or other unexpected error please call xxxxxxx
        220-and ask for "NT Support"
        220 
        USER xxxxxxx
        331 User name okay, need password.

This works ok with 'normal' ftp clients, but ftp.proxy gets stuck in
dologin waiting for the end of the server greeting. This is because the
last line of the greeting in this instance is '220<space><lf>'. The
offending code snippet is:

//--------------------ftp.c : int dologin(ftp_t *x)  -----------------

      sfgets(x, line, sizeof(line));
        while (line[3] != ' ') {
                if (sfgets(x, line, sizeof(line)) == NULL) {
                        syslog(LOG_NOTICE, "-ERR: lost server while
reading client greeting: %s", x->server.name);
                        exit (1);
                        }
                }

        if (atoi(line) != 220) {
                cfputs(x, "500 service unavailable");
                syslog(LOG_NOTICE, "-ERR: unexpected server greeting:
%s", line);
                exit (1);
                }
//--------------------------------------------------

The problem is that sfgets function removes control characters and
spaces at the end of a line. So server greetings that end without any
text after the space on the last line are not recognised. As a quick fix
I just changed the condition to:

        while (line[3] == '-') {

but I don't know if this is totally safe. After putting this fix in
everything seems to work fine.

I am not sure who is at fault here - I would welcome comments from
anyone about whether the above server greeting is 'non-standard' or if
maybe this issue has already been seen by others. As far as I can see
there is nothing to stop people using such a format.


Martin Holmes

Reply via email to