diff --git a/Changes b/Changes index e8a1705..ac47d81 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP +4.056 Wed Nov 2 19:15:31 PDT 2011 + bump rev to incorporate + improved inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + 4.055 Fri Oct 28 11:41:22 PDT 2011 in Lite.pm v1.38 patch for bug 71869, issues with Math::BigInt varients diff --git a/IP.pm b/IP.pm index b05f391..da9f96b 100644 --- a/IP.pm +++ b/IP.pm @@ -35,7 +35,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.55 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.56 $ =~ /\d+/g) }; =pod diff --git a/Lite/Changes b/Lite/Changes index ffd88e7..ebef138 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP::Lite +1.39 Wed Nov 2 19:15:31 PDT 2011 + bump rev to incorporate + improved inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + 1.38 Fri Oct 28 11:41:22 PDT 2011 patch for bug 71869, issues with Math::BigInt varients diff --git a/Lite/Lite.pm b/Lite/Lite.pm index 75b97fe..37b179f 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -31,7 +31,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.38 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.39 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; diff --git a/Lite/Util/Changes b/Lite/Util/Changes index 1f41c76..79bd979 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,9 +1,13 @@ +1.44 Wed Nov 2 19:15:31 PDT 2011 + improve inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + 1.43 Mon Oct 24 13:25:09 PDT 2011 remove reference to Config{osname} in InetBase.pm v0.03 1.42 Fri Oct 21 10:34:46 PDT 2011 Socket6 prior to version 0.23 does not have AF_INET6 in the - EXPORT_OK array, modify InetBase.pm v0.2 to work around this. + EXPORT_OK array, modify InetBase.pm v0.02 to work around this. 1.41 Sat Oct 15 17:26:21 PDT 2011 add inet_pton, inet_ntop, AF_INET, AF_INET6 diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index 6f98b48..09d1c30 100644 --- a/Lite/Util/Util.pm +++ b/Lite/Util/Util.pm @@ -21,7 +21,7 @@ @ISA = qw(Exporter DynaLoader); -$VERSION = do { my @r = (q$Revision: 1.43 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.44 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton diff --git a/Lite/Util/lib/NetAddr/IP/InetBase.pm b/Lite/Util/lib/NetAddr/IP/InetBase.pm index b7a4b56..e3b3647 100644 --- a/Lite/Util/lib/NetAddr/IP/InetBase.pm +++ b/Lite/Util/lib/NetAddr/IP/InetBase.pm @@ -11,7 +11,7 @@ @ISA = qw(Exporter); -$VERSION = do { my @r = (q$Revision: 0.03 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 0.04 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton @@ -150,17 +150,51 @@ # if Socket lib is broken in some way, check for overange values # #my $overange = yinet_aton('256.1') ? 1:0; -my $overange = gethostbyname('256.1') ? 1:0; +#my $overange = gethostbyname('256.1') ? 1:0; + +#sub inet_aton { +# unless (! $overange || $_[0] =~ /[^0-9\.]/) { # hostname +# my @dq = split(/\./,$_[0]); +# foreach (@dq) { +# return undef if $_ > 255; +# } +# } +# scalar gethostbyname($_[0]); +#} sub inet_aton { - unless (! $overange || $_[0] =~ /[^0-9\.]/) { # hostname - my @dq = split(/\./,$_[0]); - foreach (@dq) { - return undef if $_ > 255; + my $host = $_[0]; + return undef unless defined $host; + if ($host =~ /^(\d+)(?:|\.(\d+)(?:|\.(\d+)(?:|\.(\d+))))$/) { + if (defined $4) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256 && + $3 >= 0 && $3 < 256 && + $4 >= 0 && $4 < 256; + return pack('C4',$1,$2,$3,$4); +# $host = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4; + } elsif (defined $3) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256 && + $3 >= 0 && $3 < 256; + return pack('C4',$1,$2,0,$3); +# $host = ($1 << 24) + ($2 << 16) + $3; + } elsif (defined $2) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256; + return pack('C4',$1,0,0,$2); +# $host = ($1 << 24) + $2; + } else { + return pack('C4',0,0,0,$1); +# $host = $1; } +# return pack('N',$host); } - scalar gethostbyname($_[0]); -} + scalar gethostbyname($host); +} my $_zero = pack('L4',0,0,0,0); my $_ipv4mask = pack('L4',0xffffffff,0xffffffff,0xffffffff,0); diff --git a/META.yml b/META.yml index 5ef4322..04a9727 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.055 +version: 4.056 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: