You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modproxy-dev@apache.org by Alexey Panchenko <al...@liwest.ru> on 2002/08/08 09:28:30 UTC

Files from FTP servers are transmitted as text

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:alexey@liwest.ru



Re[2]: Files from FTP servers are transmitted as text

Posted by Alexey Panchenko <al...@liwest.ru>.
Hi Ian.

Thursday, August 08, 2002, 10:42:43 PM, Ian Holsman wrote:

IH> I don't know if this is the correct fix for 2.0
That function is the same in 1.3 and 2.0

IH> if you have a multi-threaded server than old_type may be changed
IH> by a different thread. maybe if we just remove 'old_type'
IH> altogether and just send out the type command all the time ?
Yes, old_type can be declared just "char old_type[2];"

-- 
Best regards,
 Alexey                            mailto:alexey@liwest.ru



Re: Files from FTP servers are transmitted as text

Posted by Ian Holsman <Ia...@cnet.com>.
On Thu, 2002-08-08 at 00:28, Alexey Panchenko wrote:
> Hi !

Hi Alexey.

I don't know if this is the correct fix for 2.0
if you have a multi-threaded server than old_type may be changed by a 
different thread.

maybe if we just remove 'old_type' altogether and just send out the type
command all the time ?

> 
> 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:alexey@liwest.ru
> 
-- 
Ian Holsman
Performance Measurement & Analysis
CNET Networks
PH: 415-344-2608