Subject: | Unable to specify "false" user data |
Date: | Tue, 25 May 2010 13:18:55 -0400 |
To: | bug-Net-Patricia [...] rt.cpan.org |
From: | Clint Hepner <clint [...] renesys.com> |
Bug: user data is overwritten with the CIDR prefix string if the
data evaluates to false.
Example:
$pt = Net::Patricia->new()
$pt->add('192.0.2.0', 24, 0) # Set user data to 0
$data = $pt->match('192.0.2.0', 24) # Returned user data is
'192.0.2.0/24', not 0
die "Wrong data" if $data ne 0
Cause: This line in the add() and add_integer() methods:
$data || = defined $bits ? "$ip/$bits" : $ip.
$data will be overwritten if it is false.
Proposed solution: Use an if statement modifier instead of the ||=
operator
$data = defined $bits ? "$ip/$bits" : $ip if @_ < 4;
Problem exists in both Net::Patricia::AF_INET and
Net::Patricia::AF_INET6 packages.
--
Clint Hepner
Renesys Corporation
clint@renesys.com