fix for bug 3168: safeguard code in NetworkUtils::ishostinsubnet, for 127.0.0.1 subnet
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14308 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
ccf2ac78b5
commit
588a72d358
@ -412,12 +412,18 @@ sub linklocaladdr {
|
||||
#-------------------------------------------------------------------------------
|
||||
sub ishostinsubnet {
|
||||
my ($class, $ip, $mask, $subnet) = @_;
|
||||
|
||||
#safe guard
|
||||
if (!defined($ip) || !defined($mask) || !defined($subnet))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
my $numbits=32;
|
||||
if ($ip =~ /:/) {#ipv6
|
||||
$numbits=128;
|
||||
}
|
||||
# IPv6 subnet with netmask postfix like /64
|
||||
if ($subnet =~ /\//)
|
||||
if ($subnet && ($subnet =~ /\//))
|
||||
{
|
||||
$subnet =~ s/\/.*$//;
|
||||
}
|
||||
@ -429,7 +435,7 @@ sub ishostinsubnet {
|
||||
$mask=getipaddr($mask,GetNumber=>1);
|
||||
}
|
||||
} else { #CIDR notation supported
|
||||
if ($subnet =~ /\//) {
|
||||
if ($subnet && ($subnet =~ /\//)) {
|
||||
($subnet,$mask) = split /\//,$subnet,2;
|
||||
$mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask)));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user