Skip Menu |

This queue is for tickets about the Net-Subnet CPAN distribution.

Report information
The Basics
Id: 92487
Status: new
Priority: 0/
Queue: Net-Subnet

Owner: Nobody in particular
Requestors: galvao.m [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: MIssing "/" in any of the subnets makes subnet_matcher's result to always answer true
Download (untitled) / with headers
text/plain 1.1k
Net-Subnet-1.03 perl v5.10.1 I can see between the caveats that there is no argument validation, but I would still suggest to change the "default" behaviour when a mask/length is not provided. Some people might think the method will default to a /32. * Code to reproduce the bug The following will print "matched" use warnings; use Net::Subnet; my $matcher = subnet_matcher qw( ); print $matcher->('') ? 'matched' : 'unmatched', "\n"; * Possible code changes When a / is not in input, either throw an exception: sub subnet_matcher { @_ > 1 and goto &multi_matcher; my ($net, $mask) = split m[/], shift; die "Invalid mask/length" if !defined($mask); return $net =~ /:/ ? ipv6_matcher($net, $mask) : ipv4_matcher($net, $mask); } or use 32/64 for the length: sub subnet_matcher { @_ > 1 and goto &multi_matcher; my ($net, $mask) = split m[/], shift; return $net =~ /:/ ? ipv6_matcher($net, $mask // 64) : ipv4_matcher($net, $mask // 32); } I didn't consider cases with the / followed by nothing/spaces, as it would make the code probably too complex.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to