Check dot1dBasePortIfIndex exists before using it (#14337)

* Check dot1dBasePortIfIndex exists before using it

Fixes: array_flip(): Can only flip STRING and INTEGER values!

* Update vlans.inc.php

* Update vlans.inc.php
This commit is contained in:
Jellyfrog 2022-09-12 15:18:43 +02:00 committed by GitHub
parent 881d581448
commit a5b1ef61bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,11 @@ $base_to_index = [];
$tmp_base_indexes = snmpwalk_cache_oid($device, 'dot1dBasePortIfIndex', [], 'BRIDGE-MIB');
// flatten the array
foreach ($tmp_base_indexes as $index => $array) {
// Broken SNMP servers can return the wrong data when OID doesn't exist
// So lets sanity check
if (! array_key_exists('dot1dBasePortIfIndex', $array)) {
continue;
}
$base_to_index[$index] = $array['dot1dBasePortIfIndex'];
}
$index_to_base = array_flip($base_to_index);