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.