Project

General

Profile

Actions

Bug #13973

closed

PHP error in ``gwlb.inc`` when OpenVPN or IPsec instances referred to by assigned interface entries are missing

Added by YP Lo almost 2 years ago. Updated over 1 year ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Interfaces
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
23.05
Release Notes:
Default
Affected Version:
2.7.0
Affected Architecture:

Description

I have previously configured OpenVPN interface and OpenVPN, but subsequently removed OpenVPN configuration but leaving in-place the OpenVPN interface.

In latest gwlb.inc, it is incorrectly trying to access the configuration item and causing PHP error...

[17-Feb-2023 01:44:16 Asia/Singapore] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /etc/inc/gwlb.inc:804
Stack trace:
#0 /etc/inc/gwlb.inc(468): return_gateways_array()
#1 /etc/inc/interfaces.inc(1560): return_gateways_status(true)
#2 /etc/inc/interfaces.inc(1739): interfaces_ipsec_vti_configure()
#3 /etc/rc.bootup(259): interfaces_configure()
#4 {main}
  thrown in /etc/inc/gwlb.inc on line 804 

An example of the configuration causing such error...

Interface definition of offending section

> <?xml version="1.0"?>
> <pfsense>
> > <version>22.8</version>
> > <lastchange></lastchange>
> > <interfaces>
> > > <opt5>
> > > > <descr><![CDATA[OPENVPN_VLAN]]></descr>
> > > > <if>ovpns1</if>
> > > > <spoofmac></spoofmac>
> > > > <enable></enable>
> > > </opt5>
> > …
> > <openvpn></openvpn>

Offending line is...


    switch ($ifcfg['ipaddr']) {

                                                 case "dhcp":

                                                 case "pppoe":

                                                 case "l2tp":

                                                 case "pptp":

                                                 case "ppp":

                                                                $ctype = strtoupper($ifcfg['ipaddr']);

                                                                break;

                                                 default:

                                                                $tunnelif = substr($ifcfg['if'], 0, 3);

                                                                if (substr($ifcfg['if'], 0, 4) == "ovpn") {

                                                                               switch (substr($ifcfg['if'], 4, 1)) {

                                                                                              case "c":

                                                                                                             $ovpntype = "openvpn-client";

                                                                                                             break;

                                                                                              case "s":

                                                                                                             $ovpntype = "openvpn-server";

                                                                                                             break;

                                                                                              default:

                                                                                                             // unknown ovpn type

                                                                                                             continue 3;

                                                                               }

                                                                               $ovpnid = substr($ifcfg['if'], 5);

                                                                               if (is_array($config['openvpn'][$ovpntype])) {

                                                                                              foreach ($config['openvpn'][$ovpntype] as & $ovpnconf) {

                                                                                                             if ($ovpnconf['vpnid'] == $ovpnid) {

                                                                                                                            // skip IPv6-only interfaces

                                                                                                                            if ($ovpnconf['create_gw'] == "v6only") {

                                                                                                                                           continue 3;

                                                                                                                            }

                                                                                                                            // skip tap interfaces

                                                                                                                            if ($ovpnconf['dev_mode'] == "tap") {

                                                                                                                                           continue 3;

                                                                                                                            }

                                                                                                             }

                                                                                              } 

Actions

Also available in: Atom PDF