Bug #7659
closedCrash "Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739" when defining a IPv4 or IPv6 IP + adding gateway.
0%
Description
RUNNING ON: pfSense-CE-2.4.0-BETA-amd64-20170623-1439.iso fresh installed today 24/6.2017 in VirtualBox and no other config done.
I was testing another bug #7452 and stumbled on a program crash bug "Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739"
when defining a IPv4 or IPv6 IP + adding gateway.
Problem is reproduceable several times and also both IPv4 and IPv6.
Seems like the data in "$gateway_settings4" or "$gateway_settings6" that is sent to function "save_gateway" in gw.inc is not equal to what it expects.
The error is as follows:
amd64 11.0-RELEASE-p10
FreeBSD 11.0-RELEASE-p10 #141 b9f3af6b8a6(RELENG_2_4): Fri Jun 23 14:46:52 CDT 2017 root@buildbot2.netgate.com:/builder/ce/tmp/obj/builder/ce/tmp/FreeBSD-src/sys/pfSense
Crash report details:
PHP Errors:
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP Warning: Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP Stack trace:
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP 1. {main}() /usr/local/www/interfaces.php:0
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP 2. save_gateway() /usr/local/www/interfaces.php:1473
No FreeBSD crash data found.
---
The coding in gw.inc where the error occurs.
GW.INC
PHP Warning: Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739
(the foreach row)
if ($gateway_settings['defaultgw'] "yes" || $gateway_settings['defaultgw'] "on") {
$i = 0;
/* remove the default gateway bits for all gateways with the same address family */
foreach ($a_gateway_item as $gw) {
if ($gateway['ipprotocol'] == $gw['ipprotocol']) {
unset($config['gateways']['gateway_item'][$i]['defaultgw']);
if ($gw['interface'] != $gateway_settings['interface'] && $gw['defaultgw']) {
$reloadif = $gw['interface'];
}
}
$i++;
}
$gateway['defaultgw'] = true;
}
INTERFACES.PHP
PHP 2. save_gateway() /usr/local/www/interfaces.php:1473
if ($_POST['gatewayip4']) {
save_gateway($gateway_settings4);
}
The data in interfaces for "$gatewayip4" is the following in interfaces.php
if ($_POST['gatewayip4']) {
// The user wants to add an IPv4 gateway - validate the settings
$gateway_settings4 = array();
$gateway_settings4['name'] = $_POST['gatewayname4'];
$gateway_settings4['interface'] = $_POST['if'];
$gateway_settings4['gateway'] = $_POST['gatewayip4'];
$gateway_settings4['descr'] = $_POST['gatewaydescr4'];
$gateway_settings4['defaultgw'] = $_POST['defaultgw4'];
Problem (crash) seems to happen every time you save the settings for IPv4 but also on IPv6 (row 1477 in "interfaces.php").
I have submitted these crashes to the devteam from pfsense.
Best regards
Dan Lundqvist
MRZAZ.COM
Files