luci-mod-status: protect against infinite recursion in port status
When attempting to resolve VLAN devices, protect against potential deep recursion due to invalid bridge configs referencing themselves. Fixes: #6648 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
575ce5512d
commit
25dd8934f1
1 changed files with 14 additions and 5 deletions
|
@ -138,15 +138,24 @@ function buildVLANMappings(mapping)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveVLANPorts(ifname, mapping)
|
function resolveVLANPorts(ifname, mapping, seen)
|
||||||
{
|
{
|
||||||
var ports = [];
|
var ports = [];
|
||||||
|
|
||||||
if (mapping[ifname])
|
if (!seen)
|
||||||
for (var i = 0; i < mapping[ifname].length; i++)
|
seen = {};
|
||||||
ports.push.apply(ports, resolveVLANPorts(mapping[ifname][i], mapping));
|
|
||||||
else
|
if (mapping[ifname]) {
|
||||||
|
for (var i = 0; i < mapping[ifname].length; i++) {
|
||||||
|
if (!seen[mapping[ifname][i]]) {
|
||||||
|
seen[mapping[ifname][i]] = true;
|
||||||
|
ports.push.apply(ports, resolveVLANPorts(mapping[ifname][i], mapping, seen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
ports.push(ifname);
|
ports.push(ifname);
|
||||||
|
}
|
||||||
|
|
||||||
return ports.sort(L.naturalCompare);
|
return ports.sort(L.naturalCompare);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue