Subject: | [Patch] is_ipv4 check the octet if it starts with zero followed by numbers |
One thing that the subroutine is_ipv4 does is it checks to make sure the
octets of the ip address are within the range of 0 - 255. However, if
the octet is 019 then this will pass.
Obviously, something like 019.8.9.1 is invalid. I have attached a patch
to fix this issue.
Subject: | validate_ipv4.patch |
--- IP-orig.pm 2007-12-06 01:04:55.000000000 -0500
+++ IP.pm 2007-12-06 01:01:53.000000000 -0500
@@ -173,7 +173,7 @@
my(@octets) = $value =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
return unless (@octets == 4);
foreach (@octets) {
- return unless ($_ >= 0 && $_ <= 255);
+ return unless ($_ >= 0 && $_ <= 255 && $_ !~ /0\d{1,2}/);
}
return join('.', @octets);