Opened 18 years ago

Last modified 18 years ago

#1179 closed Bug report

Active mode data connection is made from the wrong port

Reported by: yurivkhan Owned by:
Priority: normal Component: FileZilla Server
Keywords: Cc: yurivkhan, Tim Kosse
Component version: Operating system type:
Operating system version:

Description

According to the FTP specification (RFC0959), in active
FTP mode, the data connection should be made from port
L-1, where L is the port that the server is listening
for control connections (see section 3.2 Establishing
Data Connections, paragraph 1). This should be true for
every active mode transfer.

FileZilla Server attempts to bind the outgoing port as
per specification, but fails to do this when another
active mode data connection exists. The second
connection will get port L+1, and if a third connection
is opened, then it will get an arbitrary OS-assigned port.

Versions:

  • OS: any Windows version (tested on Windows XP SP1, SP2)
  • Server: FileZilla Server, all versions (tested on

0.9.4, 0.9.8a, 0.9.19)

  • Client: any FTP client (tested on Windows ftp.exe)

To reproduce:

  • Open two concurrent connections from the same client

host to the same server host.

  • Start downloading a large file in each connection.
  • While the files are being downloaded, run "netstat -a

-n" on the client host.

Expected behavior:

  • There are two control connections to server host,

port 21.

  • There are two data connections from server host, port 20.

Observed behavior:

  • There are two control connections to server host,

port 21.

  • There is one data connection from server host, port 20.
  • There is another data connection from server host,

unspecified port.

Cause:

  • By default, the bind() function fails if the

requested local port is already used by another socket.

  • To reuse the port, it is necessary to issue a

setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, ...) call,
passing TRUE as the option value, before binding the
socket.

Change History (1)

comment:1 by Tim Kosse, 18 years ago

The L-1 port is just a default port, it's not mandatory. And
I won't use SO_REUSEADDR since it's only causing problems,
like for example mixed up transfers.

Note: See TracTickets for help on using tickets.