From fb44b0b4b1370ab75d906c222512c603f80d1ca1 Mon Sep 17 00:00:00 2001 From: Eric Miller <> Date: Tue, 3 Apr 2007 01:25:22 +0000 Subject: [PATCH] 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. --- Info.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Info.pm b/Info.pm index 77b6c97e..d4b31d72 100644 --- a/Info.pm +++ b/Info.pm @@ -2186,7 +2186,9 @@ sub munge_mac { my $mac = shift; return undef unless defined $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()