From 2a80d1a8a2c82be409f211fcb36132204d1ac64e Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 17 Feb 2020 20:33:19 +0100 Subject: [PATCH] interfaces: make sure descriptions are properly cleansed, save description when disabled too (missed in https://github.com/opnsense/core/pull/3808) closes https://github.com/opnsense/core/issues/3942 --- src/www/interfaces.php | 2 ++ src/www/interfaces_assign.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/www/interfaces.php b/src/www/interfaces.php index b4cc01596..35aeb2ed3 100644 --- a/src/www/interfaces.php +++ b/src/www/interfaces.php @@ -576,6 +576,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $pconfig = $_POST; + $input_errors = array(); if (!empty($_POST['if']) && !empty($a_interfaces[$_POST['if']])) { $if = $_POST['if']; @@ -622,6 +623,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (isset($a_interfaces[$if]['wireless'])) { interface_sync_wireless_clones($a_interfaces[$if], false); } + $a_interfaces[$if]['descr'] = preg_replace('/[^a-z_0-9]/i', '', $pconfig['descr']); write_config("Interface {$pconfig['descr']}({$if}) is now disabled."); mark_subsystem_dirty('interfaces'); diff --git a/src/www/interfaces_assign.php b/src/www/interfaces_assign.php index 33a8912a6..7293171c2 100644 --- a/src/www/interfaces_assign.php +++ b/src/www/interfaces_assign.php @@ -152,7 +152,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $newifname = 'opt' . $i; $descr = !empty($_POST['new_entry_descr']) ? $_POST['new_entry_descr'] : 'OPT' . $i; $config['interfaces'][$newifname] = array(); - $config['interfaces'][$newifname]['descr'] = $descr; + $config['interfaces'][$newifname]['descr'] = preg_replace('/[^a-z_0-9]/i', '', $descr);; $config['interfaces'][$newifname]['if'] = $_POST['if_add']; $interfaces = list_interfaces(); if ($interfaces[$_POST['if_add']]['section'] == 'ppps.ppp') {