Re: Corrupted ftps with squid-1.02 under Linux/ELF

From: Duane Wessels <wessels>
Date: Thu, 18 Jul 96 13:41:10 -0700

jason@oit.co.uk writes:

>
>Hi there,
>
>I've just upgraded to 1.02 today, and it appears ftpget has broken. I have
>two squid servers which point at each other as neighbours (that's all.
>It's either get via UDP from the neighbour, or go DIRECT). Whenever an ftp
>occurs of a binary file (I say binary 'cause directory listings look
>fine), the file arrives corrupted. It's like the xxxx bytes are OK,
>but the rest is... This is really noticeable on gzip'ed files.

This broke because of another gzip related fix. This patch will
appear in 1.0.3, hopefully to be released later today.

Duane W.

Index: src/ftp.c
===================================================================
RCS file: /surf1/CVS/squid/src/ftp.c,v
retrieving revision 1.37.2.49
diff -w -c -r1.37.2.49 ftp.c
*** ftp.c 1996/07/08 18:30:56 1.37.2.49
--- ftp.c 1996/07/18 20:23:31
***************
*** 109,116 ****
  #define MAGIC_MARKER "\004\004\004" /* No doubt this should be more configurable */
  #define MAGIC_MARKER_SZ 3
  
- static char ftpASCII[] = "A";
- static char ftpBinary[] = "I";
  static int ftpget_server_read = -1;
  static int ftpget_server_write = -1;
  static u_short ftpget_port = 0;
--- 109,114 ----
***************
*** 135,140 ****
--- 133,139 ----
  static void ftpProcessReplyHeader _PARAMS((FtpData * data, char *buf, int size));
  static void ftpServerClosed _PARAMS((int fd, void *nodata));
  static void ftp_login_parser _PARAMS((char *login, FtpData * data));
+ static char *ftpTransferMode _PARAMS((char *urlpath));
  
  /* Global functions not declared in ftp.h */
  void ftpLifetimeExpire _PARAMS((int fd, FtpData * data));
***************
*** 459,471 ****
      }
  }
  
  void ftpSendRequest(fd, data)
       int fd;
       FtpData *data;
  {
- char *ext = NULL;
- ext_table_entry *e = NULL;
- int l;
      char *path = NULL;
      char *mode = NULL;
      char *buf = NULL;
--- 458,487 ----
      }
  }
  
+ static char *ftpTransferMode(urlpath)
+ char *urlpath;
+ {
+ static char ftpASCII[] = "A";
+ static char ftpBinary[] = "I";
+ char *ext = NULL;
+ ext_table_entry *mime = NULL;
+ int len;
+ len = strlen(urlpath);
+ if (*(urlpath + len - 1) == '/')
+ return ftpASCII;
+ if ((ext = strrchr(urlpath, '.')) == NULL)
+ return ftpBinary;
+ if ((mime = mime_ext_to_type(++ext)) == NULL)
+ return ftpBinary;
+ if (!strcmp(mime->mime_encoding, "7bit"))
+ return ftpASCII;
+ return ftpBinary;
+ }
+
  void ftpSendRequest(fd, data)
       int fd;
       FtpData *data;
  {
      char *path = NULL;
      char *mode = NULL;
      char *buf = NULL;
***************
*** 485,502 ****
      memset(buf, '\0', buflen);
  
      path = data->request->urlpath;
! l = strlen(path);
! if (path[l - 1] == '/')
! mode = ftpASCII;
! else {
! if ((ext = strrchr(path, '.')) != NULL) {
! ext++;
! mode = ((e = mime_ext_to_type(ext)) &&
! strncmp(e->mime_type, "text", 4) == 0) ? ftpASCII :
! ftpBinary;
! } else
! mode = ftpBinary;
! }
  
      /* Start building the buffer ... */
      strcat(buf, getFtpProgram());
--- 501,507 ----
      memset(buf, '\0', buflen);
  
      path = data->request->urlpath;
! mode = ftpTransferMode(path);
  
      /* Start building the buffer ... */
      strcat(buf, getFtpProgram());
Received on Thu Jul 18 1996 - 13:41:10 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:41 MST