Skip Menu |

This queue is for tickets about the Net-FTPSSL CPAN distribution.

Report information
The Basics
Id: 74035
Status: resolved
Priority: 0/
Queue: Net-FTPSSL

People
Owner: Nobody in particular
Requestors: MENDEL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.20
Fixed in: 0.21



Subject: "Use of uninitialized value in uc" on Perl 5.12.1
It seems that the behaviour of uc() for undefined values changed with recent Perl versions, it produces a warning on 5.12.1: mendel@server1:~$ perl -wE 'say $^V; my $x = uc undef;' v5.10.1 mendel@server1:~$ mendel@server2:~$ perl -wE 'say $^V; my $x = uc undef;' v5.12.1 Use of uninitialized value in uc at -e line 1. mendel@server2:~$ Consequently the code in lines 1483, 1484 and 1796 produce a warning on Perl 5.12.1. The attached patch fixes it (and includes a test for it, too).
Subject: Net-FTPSSL-0.20-uc_fix.diff
diff -Naur a/Net-FTPSSL-0.20/FTPSSL.pm b/Net-FTPSSL-0.20/FTPSSL.pm --- a/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-01 18:48:03.000000000 +0100 +++ b/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-10 16:46:23.000000000 +0100 @@ -1480,8 +1480,11 @@ # A true boolean func, should never call croak! sub supported { my $self = shift; - my $cmd = uc (shift); # uc() converts undef to "". - my $site_cmd = uc (shift); + my $cmd = shift; + my $site_cmd = shift; + + $cmd = uc ($cmd) if defined $cmd; + $site_cmd = uc ($site_cmd) if defined $site_cmd; my $result = 0; # Assume invalid FTP command @@ -1793,7 +1796,7 @@ sub _help { # Only shift off self, bug otherwise! my $self = shift; - my $cmd = uc ($_[0]); # Will convert undef to "". (Do not do a shift!) + my $cmd = defined $_[0] ? uc ($_[0]) : undef; # Do not do a shift! # Check if requesting a list of all commands or details on specific command. my $all_cmds = (! defined $_[0]); diff -Naur a/Net-FTPSSL-0.20/t/10-complex.t b/Net-FTPSSL-0.20/t/10-complex.t --- a/Net-FTPSSL-0.20/t/10-complex.t 2011-09-26 20:05:30.000000000 +0200 +++ b/Net-FTPSSL-0.20/t/10-complex.t 2012-01-16 12:55:47.000000000 +0100 @@ -14,12 +14,12 @@ # Proper values are: debug0, debug1, debug2 & debug3. 3 is the most verbose! # use IO::Socket::SSL qw(debug3); -use Test::More tests => 60; # Also update skipper (one less) +use Test::More tests => 61; # Also update skipper (one less) use File::Copy; -my $skipper = 59; +my $skipper = 60; -# plan tests => 59; # Can't use due to BEGIN block +# plan tests => 60; # Can't use due to BEGIN block BEGIN { use_ok('Net::FTPSSL') } # Test # 1 @@ -145,7 +145,14 @@ isa_ok( $ftp, 'Net::FTPSSL', 'Net::FTPSSL object creation' ); - ok( $ftp->login ($user, $pass), "Login to $server" ); + { + my $warnings = ""; + local $SIG{__WARN__} = sub { + $warnings .= $_[0]; + }; + ok( $ftp->login ($user, $pass), "Login to $server" ); + is( $warnings, "", "Login produces no warnings" ); + } # Turning off croak now that our environment is correct! $ftp->set_croak (0);
Sorry, i just noticed that i attached the wrong patch (it did not completely solve the warnings problem). This new patch does.
Subject: Net-FTPSSL-0.20-uc_fix-2.diff
diff -Naur a/Net-FTPSSL-0.20/FTPSSL.pm b/Net-FTPSSL-0.20/FTPSSL.pm --- a/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-01 18:48:03.000000000 +0100 +++ b/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-16 13:21:42.000000000 +0100 @@ -1480,8 +1480,11 @@ # A true boolean func, should never call croak! sub supported { my $self = shift; - my $cmd = uc (shift); # uc() converts undef to "". - my $site_cmd = uc (shift); + my $cmd = shift; + my $site_cmd = shift; + + $cmd = defined $cmd ? uc ($cmd) : ''; + $site_cmd = defined $site_cmd ? uc ($site_cmd) : ''; my $result = 0; # Assume invalid FTP command @@ -1793,7 +1796,7 @@ sub _help { # Only shift off self, bug otherwise! my $self = shift; - my $cmd = uc ($_[0]); # Will convert undef to "". (Do not do a shift!) + my $cmd = defined $_[0] ? uc ($_[0]) : ''; # Do not do a shift! # Check if requesting a list of all commands or details on specific command. my $all_cmds = (! defined $_[0]); diff -Naur a/Net-FTPSSL-0.20/t/10-complex.t b/Net-FTPSSL-0.20/t/10-complex.t --- a/Net-FTPSSL-0.20/t/10-complex.t 2011-09-26 20:05:30.000000000 +0200 +++ b/Net-FTPSSL-0.20/t/10-complex.t 2012-01-16 13:27:28.000000000 +0100 @@ -14,12 +14,12 @@ # Proper values are: debug0, debug1, debug2 & debug3. 3 is the most verbose! # use IO::Socket::SSL qw(debug3); -use Test::More tests => 60; # Also update skipper (one less) +use Test::More tests => 61; # Also update skipper (one less) use File::Copy; -my $skipper = 59; +my $skipper = 60; -# plan tests => 59; # Can't use due to BEGIN block +# plan tests => 60; # Can't use due to BEGIN block BEGIN { use_ok('Net::FTPSSL') } # Test # 1 @@ -145,7 +145,14 @@ isa_ok( $ftp, 'Net::FTPSSL', 'Net::FTPSSL object creation' ); - ok( $ftp->login ($user, $pass), "Login to $server" ); + { + my $warnings = ""; + local $SIG{__WARN__} = sub { + $warnings .= $_[0]; + }; + ok( $ftp->login ($user, $pass), "Login to $server" ); + is( $warnings, "", "Login produces no warnings" ); + } # Turning off croak now that our environment is correct! $ftp->set_croak (0);
Hi Norbert, Thank you for letting me know about the change in behavior with uc() in Perl 5.12. I was depending on that auto conversion from undefined to "" to avoid some checks in a few places when I used uc(). Looks like I'll have to explicitly check for this from now on. :( The fix will be in the next release, but I'm not sure when it will be out yet. If this is important to you, let me know and it will be sooner rather than later. Curtis On Mon Jan 16 07:33:56 2012, MENDEL wrote: Show quoted text
> Sorry, i just noticed that i attached the wrong patch (it did not > completely solve the warnings problem). This new patch does.
Hi Curtis, thanks for the prompt response! The release is not urgent for us (we use a packaged version of the module and we already patched it), knowing that it will contain the fix is good enough (so that we don't have to patch it again). norbi
Hi Norbert, This is just an FYI that v0.21 has finally been released with your requested fix in it. (Among others) I just uploaded it, so it will probably take a few hours to become available. Curtis On Wed Jan 18 03:41:03 2012, MENDEL wrote: Show quoted text
> Hi Curtis, > > thanks for the prompt response! The release is not urgent for us (we use > a packaged version of the module and we already patched it), knowing > that it will contain the fix is good enough (so that we don't have to > patch it again). > > norbi