mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-07-31 18:19:40 +00:00
fix(NetworkUtils): guard formatNetmask against an undefined mask
formatNetmask() uses its first argument immediately (inet_aton($mask),
2**$mask, hex $mask) with no check that it is defined. Callers that pass an
undefined mask trigger "Use of uninitialized value" warnings and a
meaningless result instead of a clean failure.
Return undef up front when $mask is not defined.
Recovered from the unmerged lenovobuild branch (original acbbeb86).
Co-authored-by: Jarrod Johnson <10814490+jjohnson42@users.noreply.github.com>
This commit is contained in:
@@ -1389,6 +1389,7 @@ sub formatNetmask
|
||||
my $origType = shift;
|
||||
my $newType = shift;
|
||||
my $maskn;
|
||||
if (not defined $mask) { return undef; }
|
||||
if ($origType == 0)
|
||||
{
|
||||
$maskn = unpack("N", inet_aton($mask));
|
||||
|
||||
Reference in New Issue
Block a user