Files from FTP servers are transmitted as text

Alexey Panchenko <[email protected]>
Newsgroups gmane.comp.apache.mod-proxy
Message-ID <[email protected]>
Hi !

The function ftp_set_TYPE in proxy_ftp.c should be fixed.
Now because of the static variable used correct type is set only once,
and all subsequent file downloads use default type, resulting in
corrupted files downloaded as text.

The simpliest fix is to remove comparision with old type value:

 /* Set ftp server to TYPE {A,I,E} before transfer of a directory or file */
 static int ftp_set_TYPE(request_rec *r, BUFF *ctrl, char xfer_type)
 {
     static char old_type[2] = {'A', '\0'};      /* After logon, mode is ASCII */
     int ret = HTTP_OK;
     int rc;
 
-    if (xfer_type == old_type[0])  // remove these lines.
-        return ret;
-
     /* set desired type */
     old_type[0] = xfer_type;
     ap_bvputs(ctrl, "TYPE ", old_type, CRLF, NULL);
     ap_bflush(ctrl);
     ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, "FTP: TYPE %s", old_type);

-- 
Best regards,
 Alexey                          mailto:[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.