Graham,

I'm using Net::FTP version 2.61, and I think I found a small bug in the passive FTP implementation in sub _dataconn. Let me start off with a diff to illustrate:

--- FTP.pm Thu Oct 16 16:08:22 2003
+++ FTP.pm.new Thu Oct 16 16:13:42 2003
@@ -914,7 +914,9 @@
{
my @port = split(/,/,${*$ftp}{'net_ftp_pasv'});


- $data = $pkg->new(PeerAddr => join(".",@port[0..3]),
+ my $ip = join(".", @port[0..3]);
+ $ip =~ s/^0//;
+ $data = $pkg->new(PeerAddr => $ip,
PeerPort => $port[4] * 256 + $port[5],
Proto => 'tcp'
);

The original line ($data = $pkg->new(PeerAddr => join(".",@port[0..3]),) just used join() to build the dotted quad IP of the peer when initiating the data connection. A problem arises when the first octet of the FTP server's IP is less than 3 digits. In this case, the servers response to the clients PASV request may be something like: Entering Passive Mode (066,218,71,198,70,41). The problem in the first octet (066) is the leading '0'. The numbers 066 and 66 pack() to different values, thus causing the data connection to most likely fail.

As you can see, my change just removes the leading 0 if it exists. This seems to work in all cases that I've tested.

Has this been reported already? Do you agree that this needs fixed?

Thanks.
Greg Miller

________
Greg Miller
Sr. System Administrator
America Online, Inc.
[EMAIL PROTECTED]
(P) 614.538.3218

Reply via email to