Subject: | Net::FTPSSL "Use of uninitialized value" (with proposed fix) |
Date: | Mon, 4 May 2009 17:38:42 -0500 |
To: | bug-Net-FTPSSL [...] rt.cpan.org |
From: | "Dennis Jenkins" <DJenkins [...] istreamfs.com> |
Hello,
First, thank you very much for Net::FTPSSL. This module is
exactly what I needed.
I am implementing an in-house FTP solution using the
Net::FTPSSL module (ver 0.08 on perl 5.8.8). I came across a bug /
issue (feature?) in that the module reports two errors about use of an
uninitialized variable when executing "$ftp->nlst" against an empty
directory on the FTP server.
The uninitialized variable is "$dati" and is defined on line
305 (at top of function "list"). By changing the line from "my $dati;"
to "my $dati = "";" the problem goes away. It works for me, but I have
not done any extensive testing against multiple servers.
This is my code (simplified) that uses your FTPSSL module:
use strict;
use Net::FTPSSL;
sub recv_process($$) {
my $ftp_user = shift;
my $ftp_pass = shift;
my $ftp = Net::FTPSSL->new($ftp_host,
Port=>$ftp_port,
Timeout=>15,
Debug=>$ftp_debug
) or die "Can't connect to $ftp_host: $@";
$ftp->login ($ftp_user, $ftp_pass) or die "FTP Error: ",
$ftp->message;
$ftp->cwd ("/Inbox") or die "FTP cwd('/Inbox') failed: ",
$ftp->message;
my @dir = $ftp->nlst ("") or die "FTP 'nlst' failed: ",
$ftp->message;
$ftp->binary() or die "FTP 'binary' failed: ", $ftp->message;
foreach my $file (@dir) {
if ($fake_it) {
print "Cowardly refusing to download file:
$file\n";
} else {
my $local_file = $download_dir . "/" . $file;
if ($verbose) {
print "Saving: $local_file\n";
}
$ftp->get ($file, $local_file) or die "FTP 'get
$file' failed ", $ftp->message;
}
}
print "\n";
$ftp->quit;
}
And the results of executing it with "Debug=>1" (user, pass, ip
obfuscated):
ftpc-1 bofa # ./bofa_xfer.pl -test -v -recv -d
SKT <<< 220 SSP FTP Server ready.
SKT >>> AUTH TLS
SKT <<< 234 Security data exchange complete.
Show quoted text
>>> USER xxxxxxxxxx
<<< 331 User name okay, need password.
Show quoted text>>> PASS *******
<<< 230 User xxxxxxxxxx logged in.
Show quoted text>>> CWD /Inbox
<<< 250 Requested file action okay, completed.
Show quoted text>>> PBSZ 0
<<< 200 PBSZ command successful.
Show quoted text>>> PROT P
<<< 200 PROT command successful.
Show quoted text>>> PASV
<<< 227 Entering Passive Mode (nnn,nnn,nnn,nnn,53,114)
Show quoted text>>> NLST
<<< 125 Data connection already open; transfer starting.
<<< 226 Closing data connection, ASCII transfer complete.
Use of uninitialized value in substitution (s///) at
/usr/lib/perl5/vendor_perl/5.8.8/Net/FTPSSL.pm line 341.
Use of uninitialized value in length at
/usr/lib/perl5/vendor_perl/5.8.8/Net/FTPSSL.pm line 385.
FTP 'nlst' failed: 226 Closing data connection, ASCII transfer complete.
at ./bofa_xfer.pl line 395.
My perl packages:
ftpc-1 bofa # equery list perl
[ Searching for package 'perl' in all categories among: ]
* installed packages
[I--] [ ] app-admin/perl-cleaner-1.05 (0)
[I--] [ ] dev-lang/perl-5.8.8-r5 (0)
[I--] [ ] sys-devel/libperl-5.8.8-r2 (1)
[I--] [ ] virtual/perl-MIME-Base64-3.07 (0)
[I--] [ ] virtual/perl-Storable-2.18 (0)
[I--] [ ] virtual/perl-Sys-Syslog-0.27 (0)
[I--] [ ] virtual/perl-Test-Harness-3.10 (0)
[I--] [ ] virtual/perl-Test-Simple-0.80 (0)
Yes, I do have a bug in my own code. $ftp->nlst() can
return no rows and that should not fail. But the issue at hand is the
errors in "FTPSSL.pm" on lines #341 and #385.
I am running a stock "perl 5.8.8" on a Gentoo Linux server.
I installed "Net::FTPSSL" using "g-cpan" to create a Gentoo portage
overlay (if you are unfamiliar, "portage" is Gentoo's package management
system).
If you need further details, please don't hesitate to
contact me. Ps- I'm not a perl wizard. I know just enough to shoot
myself in the foot.
Dennis Jenkins
Network Security Architect
iStream Financial Services
262-432-1560
CONFIDENTIALITY NOTICE
This electronic mail and the information contained herein are intended
for the named recipient only. It may contain confidential, proprietary
and/or privileged information. If you have received this electronic
mail in error, please do not read any text other than the text of this
notice and do not open any attachments. Also, please immediately notify
the sender by replying to this electronic mail or by collect call to
(262) 796-0925. After notifying the sender as described above, please
delete this electronic mail message immediately and purge the item from
the deleted items folder (or the equivalent) of your electronic mail
system. Thank you.
Message body is not shown because it is too large.