diff --git a/Changes b/Changes index 865f1e93..e5c190cc 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.046004 - 2020-10-17 + + [ENHANCEMENTS] + + * #748 even safer calls to NetAddr::MAC->new() + 2.046003 - 2020-10-17 [NEW FEATURES] diff --git a/META.json b/META.json index ba0debee..7671e567 100644 --- a/META.json +++ b/META.json @@ -128,7 +128,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.046003" + "version" : "2.046004" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -840,6 +840,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.046003", + "version" : "2.046004", "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index d7393f2f..e1e97cbb 100644 --- a/META.yml +++ b/META.yml @@ -23,7 +23,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.046003' + version: '2.046004' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -579,5 +579,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/BSD-3-Clause repository: https://github.com/netdisco/netdisco -version: '2.046003' +version: '2.046004' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index b2b46bd5..33b8d2fa 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.046003'; +our $VERSION = '2.046004'; use App::Netdisco::Configuration; =head1 NAME diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index 5b2c3b39..dae37ac0 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -418,7 +418,7 @@ Returns the C column instantiated into a L object. =cut -sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } +sub net_mac { return NetAddr::MAC->new(mac => ((shift)->mac) || '') } =head2 last_comment diff --git a/lib/App/Netdisco/DB/Result/Node.pm b/lib/App/Netdisco/DB/Result/Node.pm index 8f610d57..f898913a 100644 --- a/lib/App/Netdisco/DB/Result/Node.pm +++ b/lib/App/Netdisco/DB/Result/Node.pm @@ -193,6 +193,6 @@ Returns the C column instantiated into a L object. =cut -sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } +sub net_mac { return NetAddr::MAC->new(mac => ((shift)->mac) || '') } 1; diff --git a/lib/App/Netdisco/DB/Result/NodeIp.pm b/lib/App/Netdisco/DB/Result/NodeIp.pm index 57c40438..b27a5cb9 100644 --- a/lib/App/Netdisco/DB/Result/NodeIp.pm +++ b/lib/App/Netdisco/DB/Result/NodeIp.pm @@ -221,6 +221,6 @@ Returns the C column instantiated into a L object. =cut -sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } +sub net_mac { return NetAddr::MAC->new(mac => ((shift)->mac) || '') } 1; diff --git a/lib/App/Netdisco/DB/Result/NodeNbt.pm b/lib/App/Netdisco/DB/Result/NodeNbt.pm index abff6225..67a23b06 100644 --- a/lib/App/Netdisco/DB/Result/NodeNbt.pm +++ b/lib/App/Netdisco/DB/Result/NodeNbt.pm @@ -178,6 +178,6 @@ Returns the C column instantiated into a L object. =cut -sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } +sub net_mac { return NetAddr::MAC->new(mac => ((shift)->mac) || '') } 1; diff --git a/lib/App/Netdisco/DB/Result/NodeWireless.pm b/lib/App/Netdisco/DB/Result/NodeWireless.pm index 5c593f20..2a33d4eb 100644 --- a/lib/App/Netdisco/DB/Result/NodeWireless.pm +++ b/lib/App/Netdisco/DB/Result/NodeWireless.pm @@ -87,6 +87,6 @@ Returns the C column instantiated into a L object. =cut -sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } +sub net_mac { return NetAddr::MAC->new(mac => ((shift)->mac) || '') } 1; diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 1a7812b4..c63651e6 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -288,7 +288,7 @@ sub search_by_field { } # get IEEE MAC format - my $mac = NetAddr::MAC->new(mac => $p->{mac}); + my $mac = NetAddr::MAC->new(mac => ($p->{mac} || '')); undef $mac if ($mac and $mac->as_ieee and (($mac->as_ieee eq '00:00:00:00:00:00') @@ -401,7 +401,7 @@ sub search_fuzzy { } # get IEEE MAC format - my $mac = NetAddr::MAC->new(mac => $q); + my $mac = NetAddr::MAC->new(mac => ($q || '')); undef $mac if ($mac and $mac->as_ieee and (($mac->as_ieee eq '00:00:00:00:00:00') diff --git a/lib/App/Netdisco/Util/Node.pm b/lib/App/Netdisco/Util/Node.pm index 475afea5..73d9771a 100644 --- a/lib/App/Netdisco/Util/Node.pm +++ b/lib/App/Netdisco/Util/Node.pm @@ -68,7 +68,7 @@ sub check_mac { my ($node, $device, $port_macs) = @_; return 0 if !$node; - my $mac = NetAddr::MAC->new(mac => $node); + my $mac = NetAddr::MAC->new(mac => ($node || '')); my $devip = ($device ? (ref $device ? $device->ip : $device) : ''); $port_macs ||= {}; @@ -168,7 +168,7 @@ sub store_arp { my ($hash_ref, $now) = @_; $now ||= 'now()'; my $ip = $hash_ref->{'ip'}; - my $mac = NetAddr::MAC->new(mac => $hash_ref->{'node'}); + my $mac = NetAddr::MAC->new(mac => ($hash_ref->{'node'} || '')); my $name = $hash_ref->{'dns'}; return if !defined $mac or $mac->errstr; diff --git a/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/lib/App/Netdisco/Web/Plugin/Search/Node.pm index adfd00d4..438a0f58 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -69,7 +69,7 @@ get '/ajax/content/search/node' => require_login sub { my $agenot = param('age_invert') || '0'; my ( $start, $end ) = param('daterange') =~ m/(\d+-\d+-\d+)/gmx; - my $mac = NetAddr::MAC->new(mac => $node); + my $mac = NetAddr::MAC->new(mac => ($node || '')); undef $mac if ($mac and $mac->as_ieee and (($mac->as_ieee eq '00:00:00:00:00:00') diff --git a/lib/App/Netdisco/Web/Plugin/Search/Port.pm b/lib/App/Netdisco/Web/Plugin/Search/Port.pm index dfd770e0..ffdfb7de 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Port.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Port.pm @@ -60,7 +60,7 @@ get '/ajax/content/search/port' => require_login sub { } else { my ( $likeval, $likeclause ) = sql_match($q); - my $mac = NetAddr::MAC->new(mac => $q); + my $mac = NetAddr::MAC->new(mac => ($q || '')); undef $mac if ($mac and $mac->as_ieee diff --git a/lib/App/Netdisco/Web/Search.pm b/lib/App/Netdisco/Web/Search.pm index c9ea597e..0affb993 100644 --- a/lib/App/Netdisco/Web/Search.pm +++ b/lib/App/Netdisco/Web/Search.pm @@ -38,7 +38,7 @@ get '/search' => require_login sub { else { my $nd = $s->resultset('Device')->search_fuzzy($q); my ($likeval, $likeclause) = sql_match($q); - my $mac = NetAddr::MAC->new(mac => $q); + my $mac = NetAddr::MAC->new(mac => ($q || '')); undef $mac if ($mac and $mac->as_ieee diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 83adfe58..3da9ef52 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -203,7 +203,7 @@ sub store_neighbors { } if (!defined $neigh) { - my $mac = NetAddr::MAC->new(mac => $remote_id); + my $mac = NetAddr::MAC->new(mac => ($remote_id || '')); if ($mac and not $mac->errstr) { $neigh = $devices->single({mac => $mac->as_ieee}); } @@ -214,7 +214,7 @@ sub store_neighbors { # "myswitchname(012345-012345)" if (!defined $neigh) { (my $tmpid = $remote_id) =~ s/.*\(([0-9a-f]{6})-([0-9a-f]{6})\).*/$1$2/; - my $mac = NetAddr::MAC->new(mac => $tmpid); + my $mac = NetAddr::MAC->new(mac => ($tmpid || '')); if ($mac and not $mac->errstr) { debug sprintf ' [%s] neigh - trying to find neighbor %s by MAC %s',