From daa83f6912bee3857ab91a5158ba6ccec6f93362 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 5 Oct 2010 10:13:25 -0400 Subject: Test if variables are set before using them in certain cases, might avoid a condition where interfaces are being duplicated. (Several forum threads about it) --- config/snort/snort.inc | 14 +++++++------- config/snort/snort_interfaces_edit.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'config/snort') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index 7fd6d6ff..c9f08b11 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -99,8 +99,8 @@ function build_base_whitelist($build_netlist, $wanip, $wangw, $wandns, $vips, $v $int_array = array('lan'); for ($j = 1; isset ($config['interfaces']['opt' . $j]); $j++) if(isset($config['interfaces']['opt' . $j]['enable'])) - if(!$config['interfaces']['opt' . $j]['gateway']) - $int_array[] = "opt{$j}"; + if(isset($config['interfaces']['opt' . $j]['gateway'])) + $int_array[] = "opt{$j}"; /* iterate through interface list and write out whitelist items * and also compile a home_net list for snort. @@ -344,9 +344,9 @@ function convert_friendly_interface_to_real_interface_name2($interface) foreach ($ifdescrs as $ifdescr => $ifname) { if(strtolower($ifname) == $lc_interface) - return $config['interfaces'][$ifname]['if']; - if(strtolower($config['interfaces'][$ifname]['descr']) == $lc_interface) - return $config['interfaces'][$ifname]['if']; + return $config['interfaces'][$ifname]['if']; + if(isset($config['interfaces'][$ifname]['descr']) && (strtolower($config['interfaces'][$ifname]['descr']) == $lc_interface)) + return $config['interfaces'][$ifname]['if']; } return $interface; @@ -2318,8 +2318,8 @@ function generate_snort_conf($id, $if_real, $snort_uuid) $automaticrulesupdate = $config['installedpackages']['snortglobal']['automaticrulesupdate7']; /* if user is on pppoe, we really want to use ng0 interface */ - if($config['interfaces'][$snort_ext_int]['ipaddr'] == "pppoe") - $snort_ext_int = "ng0"; + if(isset($config['interfaces'][$snort_ext_int]['ipaddr']) && ($config['interfaces'][$snort_ext_int]['ipaddr'] == "pppoe")) + $snort_ext_int = "ng0"; /* set the snort performance model */ if($config['installedpackages']['snortglobal']['rule'][$id]['performance']) diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php index e7df2243..6b3b3a55 100644 --- a/config/snort/snort_interfaces_edit.php +++ b/config/snort/snort_interfaces_edit.php @@ -484,7 +484,7 @@ echo " foreach($if_array as $iface2) { $if2 = convert_friendly_interface_to_real_interface_name2($iface2); - if($config['interfaces'][$iface2]['ipaddr'] == "pppoe") { + if(isset($config['interfaces'][$iface2]['ipaddr']) && ($config['interfaces'][$iface2]['ipaddr'] == "pppoe")) { $if2 = "ng0"; } -- cgit v1.2.3