Only return MAC from munge_mac() if it actually is a MAC. Fix for netdisco where device would not be inserted in DB due to malformed MAC.

This commit is contained in:
Eric Miller
2007-04-03 01:25:22 +00:00
parent 09f80eeed7
commit fb44b0b4b1

View File

@@ -2186,7 +2186,9 @@ sub munge_mac {
my $mac = shift; my $mac = shift;
return undef unless defined $mac; return undef unless defined $mac;
return undef unless length $mac; return undef unless length $mac;
return join(':',map { sprintf "%02x",$_ } unpack('C*',$mac)); $mac = join(':',map { sprintf "%02x",$_ } unpack('C*',$mac));
return $mac if $mac =~ /^([0-9A-F][0-9A-F]:){5}[0-9A-F][0-9A-F]$/i;
return undef;
} }
=item munge_octet2hex() =item munge_octet2hex()