# New Ticket Created by "NEWPORT Dennis" # Please include the string: [perl #82720] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=82720 > We have found another bug but this time in Net::FTP::dataconn.pm. Namely: The problems occurred when connecting to ProFTPD 1.3.3d. When trying to get a list of files using a pattern that doesn't match any files the following error occurred: Can't use an undefined value as a symbol reference at ..../Net/FTP/dataconn.pm line 54. The problem seems to be that when the NLST command is sent and the client attempts to open the data connection, the ftp server refuses the connection. This results in the $ftp variable not being set. It is not clear if this behaviour is correct or a bug in the FTP server. The changes that we think work are highlighted in red below. Also I think you should change the "unique file name" check to also check for FILE: as per my previous mail. We tried that as well and it works fine. Thanks. sub _close { my $data = shift; my $ftp = ${*$data}{'net_ftp_cmd'}; $data->SUPER::close(); return if !defined $ftp; delete ${*$ftp}{'net_ftp_dataconn'} if exists ${*$ftp}{'net_ftp_dataconn'} && $data == ${*$ftp}{'net_ftp_dataconn'}; } sub close { my $data = shift; my $ftp = ${*$data}{'net_ftp_cmd'}; if(exists ${*$data}{'net_ftp_bytesread'} && !${*$data}{'net_ftp_eof'}) { my $junk; $data->read($junk,1,0); return $data->abort unless ${*$data}{'net_ftp_eof'}; } $data->_close; return if !defined $ftp; $ftp->response() == CMD_OK && $ftp->message =~ /unique file name:\s*(\S*)\s*\)/ && (${*$ftp}{'net_ftp_unique'} = $1); $ftp->status == CMD_OK; } --------------------- Dennis Newport Central Flow Management Unit Eurocontrol Raketstraat 96 B-1130 Brussels Belgium email: dennis.newport@eurocontrol.int <mailto:dennis.newport@eurocontrol.int> tel: +32 2 729 9621 fax: +32 2 729 9703 GSM: +32 499 943624 ________________________________ From: NEWPORT Dennis Sent: Tuesday 18 January 2011 08:07 To: 'bug-perl@rt.cpan.org' Subject: Bug in Net::FTP.pm Background: OS: RedHat 5, 2.6.18-92.el5 Module: Net::FTP.pm, version 2.78 We used to use wu-ftpd on HP-UX and then migrated to vsftpd on our new RedHat linux machines. But vsftpd was not good at for some of our pattern matching and wildcarding requirements on filenames so we have now upgraded to ProFTPD. This is where the problem has occurred. We use a Perl script to do some of our ftp'ing. It uses Net::FTP.pm. In this we call put_unique. The problem is that the wu-ftpd and vsftpd ftp implementations returned a string that said something like: <<< 226 Transfer complete (unique file name:TEST_FILE). where TEST_FILE was the name of the file we were ftp'ing, whereas ProFTPD returns a sting that says: <<< 150 FILE: ftpZpQr2p where ftpZpQr2p is the name given to the unique file. But in this latter case, this string (ftpZpQr2p) is not returned from put_unique. That is because in the _store_cmd subroutine there is this line: if ('STOU' eq uc $cmd and $ftp->message =~ m/unique\ file\ name:(.*)\)|"(.*)"/) If this is changed to: if ('STOU' eq uc $cmd and ($ftp->message =~ m/unique\ file\ name:(.*)\)|"(.*)"/ or $ftp->message =~ m/FILE:\ (.*)/)) then put_unique behaves as documented. I've tested this and it works with wu-ftpd, vsftpd and ProFTPD. Thanks. --------------------- Dennis Newport Central Flow Management Unit Eurocontrol Raketstraat 96 B-1130 Brussels Belgium email: dennis.newport@eurocontrol.int <mailto:dennis.newport@eurocontrol.int> tel: +32 2 729 9621 fax: +32 2 729 9703 GSM: +32 499 943624 ____ This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful. Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy. Any views expressed in this message are those of the sender.