Hi,
I'm using Set::IntervalTree in Net::IPAddress::Filter as it's by far the
smallest and fastest way I've found for dealing with large IP address
filter lists.
In testing I found that fetch(2^31, 2^31) reports a false positive if
the tree has at least one interval, even if that interval doesn't span 2^31
The following code shows it happening.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Set::IntervalTree;
my $tree = Set::IntervalTree->new();
my $min = 1;
my $max = 2;
my $test = 2_147_483_648; # 2^31 - Shouldn't match but does
print Dumper( $tree->fetch( $test, $test ) ); # prints []
$tree->insert( "$min - $max", $min, $max );
print Dumper( $tree->fetch( $test - 1, $test - 1 ) ); # prints []
print Dumper( $tree->fetch( $test, $test ) ); # prints [ '1 -
2' ]
print Dumper( $tree->fetch( $test + 1, $test + 1 ) ); # prints []
print Dumper( $tree->fetch( $test - 1, $test + 1 ) ); # prints []
exit;
My C is non-existent at best, and I couldn't spot where this bug arises.
Thanks for this light and fast module.
Dave