From f1d7efc66179d0e6f89ba1c2d07ccf4d01bf0e50 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 24 Mar 2015 07:54:34 +0100 Subject: [PATCH] vpn: is_array($x) && is_array($x) -> isset($x) I guess this is a typo. It makes sense to preceede is_array() with isset() here since PHP throws a warning on unset variables nowadays. However, is_array() should not be used if the following operation is `foreach' as it would mask the fact that the array that is set is not an array at all (maybe due to a bug). Rather want to catch it instead. A bit of style along the way and `lint' target fixing. --- Makefile | 2 +- src/etc/inc/vpn.inc | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 859ffaf42..b2a8dd90d 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ lint: ! -name "*.svg" ! -name "*.woff" ! -name "*.woff2" \ ! -name "*.otf" ! -name "*.png" ! -name "*.js" \ ! -name "*.scss" ! -name "*.py" ! -name "*.ttf" \ - -type f -print0 | xargs -0 -n1 php -l + ! -name "*.tgz" -type f -print0 | xargs -0 -n1 php -l sweep: find ${.CURDIR}/src ! -name "*.min.*" ! -name "*.svg" \ diff --git a/src/etc/inc/vpn.inc b/src/etc/inc/vpn.inc index 534f0a0cd..113c501a9 100644 --- a/src/etc/inc/vpn.inc +++ b/src/etc/inc/vpn.inc @@ -193,27 +193,31 @@ function vpn_ipsec_configure($ipchg = false) } $rgmap[$ph1ent['remote-gateway']] = $rg; - if (is_array($a_phase2) && is_array($a_phase2)) { + if (isset($a_phase2)) { /* step through each phase2 entry */ foreach ($a_phase2 as $ph2ent) { - if (isset($ph2ent['disabled'])) + if (isset($ph2ent['disabled'])) { continue; + } - if ($ikeid != $ph2ent['ikeid']) + if ($ikeid != $ph2ent['ikeid']) { continue; + } /* add an ipsec pinghosts entry */ if ($ph2ent['pinghost']) { - if (!is_array($iflist)) + if (!is_array($iflist)) { $iflist = get_configured_interface_list(); + } $viplist = get_configured_vips_list(); $srcip = null; $local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true, $ph2ent['mode']); if(is_ipaddrv6($ph2ent['pinghost'])) { foreach ($iflist as $ifent => $ifname) { $interface_ip = get_interface_ipv6($ifent); - if(!is_ipaddrv6($interface_ip)) + if (!is_ipaddrv6($interface_ip)) { continue; + } if (ip_in_subnet($interface_ip, $local_subnet)) { $srcip = $interface_ip; break; @@ -222,8 +226,9 @@ function vpn_ipsec_configure($ipchg = false) } else { foreach ($iflist as $ifent => $ifname) { $interface_ip = get_interface_ip($ifent); - if(!is_ipaddrv4($interface_ip)) + if (!is_ipaddrv4($interface_ip)) { continue; + } if ($local_subnet == "0.0.0.0/0" || ip_in_subnet($interface_ip, $local_subnet)) { $srcip = $interface_ip; break;