spamassassin-users October 2010 archive
Main Archive Page > Month Archives  > spamassassin-users archives
spamassassin-users: Re: SA 3.3.1 and NetAddr::IP 4.034

Re: SA 3.3.1 and NetAddr::IP 4.034

From: Mark Martinec <Mark.Martinec+sa_at_nospam>
Date: Thu Oct 28 2010 - 15:23:17 GMT
To: users@spamassassin.apache.org

> > Looks like a but in NetAddr::IP 4.034, it forgets to adjust the CIDR
> > mask when converting an IPv4 address to an IPv6 notation:

s/but/BUG/ :)

> > correct (NetAddr-IP-4.033):
> > $ perl -le 'use NetAddr::IP; print NetAddr::IP->new6("127.0.0.0/8")'
> > 0:0:0:0:0:0:7F00:0/104
> >
> > wrong (NetAddr-IP-4.034):
> > $ perl -le 'use NetAddr::IP; print NetAddr::IP->new6("127.0.0.0/8")'
> > 0:0:0:0:0:0:7F00:0/8

> Mmmh.
> In fact it seems they bobbed few lines from 4.033...

The offending change is:

--- NetAddr-IP-4.033/Lite/Lite.pm 2010-09-29 19:35:16.000000000 +0200
+++ NetAddr-IP-4.034/Lite/Lite.pm 2010-10-26 01:20:12.000000000 +0200
@@ -696,3 +696,3 @@
     if ($mask =~ /^(\d+)$/) {
- if (index($ip,':') < 0) { # is ipV4
+ if (! $isV6 && index($ip,':') < 0) { # is ipV4
        if ($1 == 32) { # cidr 32

(which is in fact the only functional change in 4.034)

> You sure new6 may be used with IPv4 address, huh?

Yes. According to docs:

   Methods
       "->new([$addr, [ $mask|IPv6 ]])"
       "->new6([$addr, [ $mask]])"
       "->new_no([$addr, [ $mask]])"
       "->new_from_aton($netaddr)"
           The first two methods create a new address with the supplied
           address in $addr and an optional netmask $mask
[...]
           "->new6" marks the address as being in ipV6 address space even if
           the format would suggest otherwise.

             i.e. ->new6('1.2.3.4') will result in ::102:304

             addresses submitted to ->new in ipV6 notation will
             remain in that notation permanently. i.e.
                   ->new('::1.2.3.4') will result in ::102:304
             whereas new('1.2.3.4') would print out as 1.2.3.4

           $addr can be almost anything that can be resolved to an IP address
           in all the notations I have seen over time. It can optionally
           contain the mask in CIDR notation.

> If you confirm this, I can take care of reporting the bug to upstream.

Please do so, thanks!

  Mark