|
|
|
|
||||||
| comp.protocols.tcp-ip TCP and IP network protocols. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi All,
I was using the Net::IP perl 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 ... |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Jigs wrote: > Hi All, > > I was using the Net::IP perl 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? A recent thread on this very topic: http://groups.google.com/group/comp....ad8dd986?hl=en |
|
![]() |
| Outils de la discussion | |
|
|