Actions
Bug #2956
closedlookup_gateway_ip_by_name() (in gwlb.inc) might return the wrong IP if the gateway has an entirely numeric name
Start date:
04/18/2013
Due date:
% Done:
100%
Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
All
Affected Architecture:
Description
I have two gateways, named "1812" and "1812v6", with "1812" being first in the list. When this function is called asking for the IP of "1812v6", the IP for "1812" is returned. This seems to be because PHP is being clever and treating $gname in this code as an integer, and thus converting $name to an integer in the comparison ("1812v6" gets converted to 1812, which matches the wrong gateway):
function lookup_gateway_ip_by_name($name) { $gateways_arr = return_gateways_array(false, true); foreach ($gateways_arr as $gname => $gw) { if ($gw['name'] == $name || $gname == $name) return $gw['gateway']; } return false; }
The following change seems to force a string comparison (which is what you want to do):
- if ($gw['name'] == $name || $gname == $name) + if ($gw['name'] == "$name" || "$gname" == "$name")
Might wanna double-check that though, I try to avoid PHP these days because of stupidities like that.
Actions