Project

General

Profile

Bug #7659

Crash "Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739" when defining a IPv4 or IPv6 IP + adding gateway.

Added by Dan Lundqvist about 2 years ago. Updated about 2 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
Interfaces
Target version:
Start date:
06/24/2017
Due date:
% Done:

0%

Estimated time:
Affected Version:
2.4
Affected Architecture:

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 :/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

ErrorReport.txt (1.4 KB) ErrorReport.txt Printouts for crashes. Dan Lundqvist, 06/24/2017 10:50 AM

History

#2 Updated by Dan Lundqvist about 2 years ago

Hi Philip,

I updated the PF to 2.4.0-BETA (amd64) built on Wed Jun 28 16:02:43 CDT 2017 today and redid the procedure and now there is no crash from what I could see.
Also checked the /etc/inc/gwlb.inc and it contained your merged pull. So I think we could close this ticket.

Thanks.

Best regards
Dan Lundqvist
MRZAZ.COM

#3 Updated by Jim Pingle about 2 years ago

  • Status changed from New to Resolved

#4 Updated by Jim Pingle about 2 years ago

  • Target version changed from 2.4.0 to 2.3.4-p1

Also available in: Atom PDF