Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

system/3378: ftp-proxy fails processing some multiline server responses

From: <mayonez(at)ssnet.xim.pl>
Date: Tue Jul 29 2003 - 10:16:04 EDT


>Number: 3378
>Category: system
>Synopsis: ftp-proxy fails processing some multiline server responses
>Confidential: yes
net
>Environment:
        

	System      : OpenBSD 3.3
	Architecture: OpenBSD.i386
	Machine     : i386

>Description:

ftp-proxy doesnt handle server responses properly. The problem occurs while dealing with multiline responses. When a non-first line begins with a number, it wrongly interprets the number as ftp response code which makes the next line (without number) produce the following failure:
ftp-proxy[5871]: invalid server reply code 0

>How-To-Repeat:

Set up a NAT box and configure ftp-proxy like in ftp-proxy(8) Try to connect to an external server from a host from internal network. I got something like this:

$ ftp ftp.netbsd.org:/
Trying 2001:4f8:4:7:2e0:81ff:fe21:6563... ftp: connect to address 2001:4f8:4:7:2e0:81ff:fe21:6563: No route to host Trying 204.152.184.75...
Connected to ftp.netbsd.org.
220 ftp.NetBSD.org FTP server (NetBSD-ftpd 20020615) ready. 331 Guest login ok, type your name as password. 230-

    The NetBSD Project FTP Server located in Redwood City, CA, USA

    100 Mbps connectivity courtesy of                      ,        ,
/* because of ' 100' - error in processing the next line */ 421 Service not available, remote server has closed connection.
ftp: Login failed.
ftp: No control connection for command.
ftp: Login failed.
ftp: No control connection for command.
ftp: Can't connect or login to host `ftp.netbsd.org'

Most of ftp daemons send multiline reply like

220-
220-                 Welcome to SunSITE Alberta
220-

so it's not a common problem

>Fix:

strtol() accepts leading spaces and that is the problem the following patch fixes it (for 3.3-current):

  • ftp-proxy.c.orig Tue Jul 29 15:35:07 2003 --- ftp-proxy.c Tue Jul 29 15:32:12 2003
  • 861,866 **** --- 861,868 ----
    • Watch out for "227 Entering Passive Mode ..." replies */ code = strtol((char *)server->line_buffer, &p, 10); + if (isspace(server->line_buffer[0])) + code = 0; if (!*(server->line_buffer) || (*p != ' ' && *p != '-')) { if (continuing) goto sendit;

...
Now I can finally download NetBSD :>

>Release-Note:
Received on Tue Jul 29 10:56:08 2003

Do you need help?X

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:30:06 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library