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.
Updated by Chris Buechler over 11 years ago
- Category changed from Web Interface to Gateways
- Target version set to 2.1
Updated by Renato Botelho over 11 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
Applied in changeset d97eccf9fdee3c753f6ae5ed222dba7ae3448a21.
Updated by Renato Botelho over 11 years ago
Applied in changeset ecf8dba773705303bba39feed529d2b8f7f0577f.
Updated by Renato Botelho over 11 years ago
- Status changed from Feedback to Resolved
Actions