Skip to content

Commit c3fd510

Browse files
committed
fix: Fix network ports ip support to avoid possible wrong allocation
1 parent 56f0f81 commit c3fd510

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Changes

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ inventory:
99
netdiscovery/netinventory:
1010
* PR #836 from @eduardomozart: Enhanced HP wireless printers by reporting wifi ports
1111
as wireless
12+
* Fix network ports ip support to avoid wrong allocation in rare cases, seen on a Ricoh printer
1213

1314
packaging:
1415
* Update Windows MSI packing building process to use:

lib/GLPI/Agent/Tools/Hardware.pm

+5-3
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,10 @@ sub _setGenericProperties {
625625
foreach my $suffix (sort keys %{$results}) {
626626
my $value = $results->{$suffix};
627627
next unless $value;
628+
# value must match IFNUMBER
629+
my $portindex = first { $ports->{$_}->{IFNUMBER} eq $value } keys(%{$ports});
628630
# safety checks
629-
if (! exists $ports->{$value}) {
631+
unless ($portindex) {
630632
$logger->debug(
631633
"unknown interface $value for IP address $suffix, ignoring"
632634
) if $logger;
@@ -636,8 +638,8 @@ sub _setGenericProperties {
636638
$logger->debug("invalid IP address $suffix") if $logger;
637639
next;
638640
}
639-
$ports->{$value}->{IP} = $suffix;
640-
push @{$ports->{$value}->{IPS}->{IP}}, $suffix;
641+
$ports->{$portindex}->{IP} = $suffix;
642+
push @{$ports->{$portindex}->{IPS}->{IP}}, $suffix;
641643
}
642644

643645
$device->{PORTS}->{PORT} = $ports;

0 commit comments

Comments
 (0)