From:             [EMAIL PROTECTED]
Operating system: Maybe All platform
PHP version:      4.1.1
PHP Bug Type:     FTP related
Bug description:  ftp_getresp()'s bug when ftp server returns multiple response code 

Hello.

When ftp-server returns multiple response code, ftp_nlist() and
ftp_rawlist() is hung.

First response code is set normaly.
but second response code isn't set and ftp_get_resp() triing call
ftp_readline() until ftp-timeout.

I change ftp_getresp in ftp.c

int
ftp_getresp(ftpbuf_t *ftp)
{
    char *buf;

    if (ftp == NULL) return 0;
    buf = ftp->inbuf;
    ftp->resp = 0;

    while (1) {

        if (!ftp_readline(ftp)) {
            return 0;
        }

        /* Break out when the end-tag is found */
        if (isdigit(ftp->inbuf[0]) && 
            isdigit(ftp->inbuf[1]) && 
            isdigit(ftp->inbuf[2]) && 
            ftp->inbuf[3] == ' ') {
            break;
        }
    }

    /* translate the tag */
    if (!isdigit(ftp->inbuf[0]) ||
        !isdigit(ftp->inbuf[1]) ||
        !isdigit(ftp->inbuf[2]))
    {
        return 0;
    }

    ftp->resp = 100 * (ftp->inbuf[0] - '0') +
                 10 * (ftp->inbuf[1] - '0') +
                      (ftp->inbuf[2] - '0');

    memmove(ftp->inbuf, ftp->inbuf + 4, FTP_BUFSIZE - 4);
    if(ftp->extra)
        ftp-extra -= 4;
    return 1;
}

-- 
Edit bug report at: http://bugs.php.net/?id=15296&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to