Skip Menu |

This queue is for tickets about the NetAddr-IP CPAN distribution.

Report information
The Basics
Id: 65888
Status: resolved
Worked: 15 min
Priority: 0/
Queue: NetAddr-IP

People
Owner: michael [...] bizsystems.com
Requestors: quanah.gibsonmount [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 4.018
  • 4.019
  • 4.020
  • 4.021
  • 4.022
  • 4.023
  • 4.024
  • 4.025
  • 4.026
  • 4.027
  • 4.028
  • 4.029
  • 4.030
  • 4.032
  • 4.033
  • 4.034
  • 4.035
  • 4.036
  • 4.037
  • 4.038
  • 4.039
Fixed in: (no value)



Subject: http://search.cpan.org/CPAN/authors/id/M/MI/MIKER/NetAddr-IP-4.039.tar.gz
From the amavisd-new list: Henrik, Show quoted text
> Jan 31 11:08:53 xxx amavis[1058]: (01058) _WARN: Use of uninitialized > value in concatenation (.) or string at > /usr/local/perl/lib/site_perl/5.12.1/Mail/SPF/Util.pm line 109, <GEN25> > line 22. > Jan 31 11:08:53 xxx amavis[1058]: (01058) _WARN: spf: lookup failed: > Bad arg length for NetAddr::IP::Util::sub128, length is 0, should be > 128 at > /usr/local/perl/lib/site_perl/5.12.1/i686-linux/NetAddr/IP/Lite.pm > line 1131. > > If I run spamassassin from command line, I don't get any warnings. > Any ideas?
The difference is that amavisd sees NetAddr/IP/Lite/Util/Util.pm as autosplit modules, while a command line spamassassin happens to load it in its entirety. There is a bug in NetAddr-IP (actually two), which only shows when its modules are autoloaded. Here is a patch on NetAddr-IP-4.038: --- Lite/Util/Util.pm~ 2010-11-19 19:14:15.000000000 +0100 +++ Lite/Util/Util.pm 2011-02-01 01:07:10.000000000 +0100 @@ -116,6 +116,9 @@ # allow user to choose upper or lower case -my $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; -my $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; +BEGIN { + use vars qw($n2x_format $n2d_format); + $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; + $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; +} sub upper { $n2x_format = uc($n2x_format); $n2d_format = uc($n2d_format); } @@ -474,4 +477,5 @@ my($nadr) = @_; if (isIPv4($nadr)) { + local $1; ipv6_n2d($nadr) =~ /([^:]+)$/; return $1; @@ -495,4 +499,5 @@ my $addr = ipv6_n2d($nadr); return $addr unless isIPv4($nadr); + local $1; $addr =~ /([^:]+)$/; return $1; The main bug comes from the fact that package lexicals are not visible in autoloaded modules, which is why $n2d_format and $n2x_format strings are seen as undefined by ipv6_n2d() and ipv6_n2x(). $ man AutoLoader Package Lexicals Package lexicals declared with "my" in the main block of a package using AutoLoader will not be visible to auto-loaded subroutines, due to the fact that the given scope ends at the "__END__" marker. A module using such variables as package globals will not work properly under the AutoLoader. The "vars" pragma (see "vars" in perlmod) may be used in such situations as an alternative to explicitly qualifying all globals with the package namespace. Variables pre-declared with this pragma will be visible to any autoloaded routines (but will not be invisible outside the package, unfortunately). A secondary bug comes from the fact that (as a consequence of the above) the following regexp in inet_n2dx() does not match, as ipv6_n2d($nadr) is empty: ipv6_n2d($nadr) =~ /([^:]+)$/; return $1; and the inet_n2dx() returns whatever garbage happens to be in a global variable $1, which subsequently ends up as a result of NetAddr::IP::Lite::cidr and in a stringified address.
Suggestions below have been implemented in NetAddr::IP v4.040 and uploaded to CPAN. Thank you for finding the bug and providing a good solution. Who could ask for more ;-) Michael On Fri Feb 18 16:18:44 2011, MISHIKAL wrote: Show quoted text
> From the amavisd-new list: > > Henrik, >
> > Jan 31 11:08:53 xxx amavis[1058]: (01058) _WARN: Use of uninitialized > > value in concatenation (.) or string at > > /usr/local/perl/lib/site_perl/5.12.1/Mail/SPF/Util.pm line 109, <GEN25> > > line 22. > > Jan 31 11:08:53 xxx amavis[1058]: (01058) _WARN: spf: lookup failed: > > Bad arg length for NetAddr::IP::Util::sub128, length is 0, should be > > 128 at > > /usr/local/perl/lib/site_perl/5.12.1/i686-linux/NetAddr/IP/Lite.pm > > line 1131. > > > > If I run spamassassin from command line, I don't get any warnings. > > Any ideas?
> > The difference is that amavisd sees NetAddr/IP/Lite/Util/Util.pm > as autosplit modules, while a command line spamassassin happens > to load it in its entirety. > > There is a bug in NetAddr-IP (actually two), which only shows when > its modules are autoloaded. Here is a patch on NetAddr-IP-4.038: > > --- Lite/Util/Util.pm~ 2010-11-19 19:14:15.000000000 +0100 > +++ Lite/Util/Util.pm 2011-02-01 01:07:10.000000000 +0100 > @@ -116,6 +116,9 @@ > # allow user to choose upper or lower case > > -my $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; > -my $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; > +BEGIN { > + use vars qw($n2x_format $n2d_format); > + $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; > + $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; > +} > > sub upper { $n2x_format = uc($n2x_format); $n2d_format =
uc($n2d_format); } Show quoted text
> @@ -474,4 +477,5 @@ > my($nadr) = @_; > if (isIPv4($nadr)) { > + local $1; > ipv6_n2d($nadr) =~ /([^:]+)$/; > return $1; > @@ -495,4 +499,5 @@ > my $addr = ipv6_n2d($nadr); > return $addr unless isIPv4($nadr); > + local $1; > $addr =~ /([^:]+)$/; > return $1; > > > The main bug comes from the fact that package lexicals are not visible > in autoloaded modules, which is why $n2d_format and $n2x_format strings > are seen as undefined by ipv6_n2d() and ipv6_n2x(). > > $ man AutoLoader > > Package Lexicals > Package lexicals declared with "my" in the main block of a package > using AutoLoader will not be visible to auto-loaded subroutines, > due to > the fact that the given scope ends at the "__END__" marker. A
module Show quoted text
> using such variables as package globals will not work properly
under Show quoted text
> the AutoLoader. > > The "vars" pragma (see "vars" in perlmod) may be used in such > situations as an alternative to explicitly qualifying all globals > with > the package namespace. Variables pre-declared with this pragma > will be > visible to any autoloaded routines (but will not be invisible
outside Show quoted text
> the package, unfortunately). > > A secondary bug comes from the fact that (as a consequence of the
above) the Show quoted text
> following regexp in inet_n2dx() does not match, as ipv6_n2d($nadr) is
empty: Show quoted text
> > ipv6_n2d($nadr) =~ /([^:]+)$/; > return $1; > > and the inet_n2dx() returns whatever garbage happens to be in > a global variable $1, which subsequently ends up as a result > of NetAddr::IP::Lite::cidr and in a stringified address.