J
Jigs
Hi All,
I was using the Net::IP module from CPAN and the function to validate
an IP address allows single numbers to be a valid address. Here is the
snippet from the function ip_is_ipv4:
# Single Numbers are considered to be IPv4
if ($ip =~ m/^(\d+)$/ and $1 < 256) { return 1 }
# Count quads
my $n = ($ip =~ tr/\./\./);
# IPv4 must have from 1 to 4 quads
unless ($n >= 0 and $n < 4) {
$ERROR = "Invalid IP address $ip";
$ERRNO = 105;
return 0;
}
Can someone please explain why single numbers are valis IP addresses?
Thank in advance ...
Jigs
I was using the Net::IP module from CPAN and the function to validate
an IP address allows single numbers to be a valid address. Here is the
snippet from the function ip_is_ipv4:
# Single Numbers are considered to be IPv4
if ($ip =~ m/^(\d+)$/ and $1 < 256) { return 1 }
# Count quads
my $n = ($ip =~ tr/\./\./);
# IPv4 must have from 1 to 4 quads
unless ($n >= 0 and $n < 4) {
$ERROR = "Invalid IP address $ip";
$ERRNO = 105;
return 0;
}
Can someone please explain why single numbers are valis IP addresses?
Thank in advance ...
Jigs