Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...System_Patches/files/usr/local/pkg/patches/c5b8e57aa51ff82b45bd6cb925ba512f4c01dcba.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
commit c5b8e57aa51ff82b45bd6cb925ba512f4c01dcba | ||
Author: jim-p <jimp@netgate.com> | ||
Date: Tue Feb 28 15:53:19 2023 -0500 | ||
|
||
Improve validation and escaping of bridge interfaces. Fixes #14052 | ||
|
||
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc | ||
index 39d353ccdf..5e0ccfab74 100644 | ||
--- a/src/etc/inc/interfaces.inc | ||
+++ b/src/etc/inc/interfaces.inc | ||
@@ -753,7 +753,7 @@ function interface_bridge_configure(&$bridge, $checkmember = 0, $flush = true) { | ||
|
||
function interface_bridge_configure_stp($bridge) { | ||
if (isset($bridge['enablestp'])) { | ||
- $bridgeif = trim($bridge['bridgeif']); | ||
+ $bridgeif = escapeshellarg(trim($bridge['bridgeif'])); | ||
/* configure spanning tree proto */ | ||
mwexec("/sbin/ifconfig {$bridgeif} proto " . escapeshellarg($bridge['proto'])); | ||
|
||
@@ -811,7 +811,7 @@ function interface_bridge_configure_stp($bridge) { | ||
} | ||
|
||
function interface_bridge_configure_advanced($bridge) { | ||
- $bridgeif = trim($bridge['bridgeif']); | ||
+ $bridgeif = escapeshellarg(trim($bridge['bridgeif'])); | ||
|
||
if ($bridge['maxaddr'] <> "") { | ||
mwexec("/sbin/ifconfig {$bridgeif} maxaddr " . escapeshellarg($bridge['maxaddr'])); | ||
@@ -871,7 +871,7 @@ function interface_bridge_configure_advanced($bridge) { | ||
} | ||
|
||
function interface_bridge_configure_ip6linklocal($bridge) { | ||
- $bridgeif = trim($bridge['bridgeif']); | ||
+ $bridgeif = escapeshellarg(trim($bridge['bridgeif'])); | ||
|
||
$members = explode(',', $bridge['members']); | ||
if (!count($members)) { | ||
@@ -884,7 +884,7 @@ function interface_bridge_configure_ip6linklocal($bridge) { | ||
|
||
mwexec("/usr/sbin/ndp -i {$bridgeif} -- {$bridgeop}auto_linklocal"); | ||
foreach ($members as $member) { | ||
- $realif = get_real_interface($member); | ||
+ $realif = escapeshellarg(get_real_interface($member)); | ||
mwexec("/usr/sbin/ndp -i {$realif} -- {$memberop}auto_linklocal"); | ||
} | ||
} | ||
diff --git a/src/usr/local/www/interfaces_bridge_edit.php b/src/usr/local/www/interfaces_bridge_edit.php | ||
index d912fa25e6..58b07ca8f2 100644 | ||
--- a/src/usr/local/www/interfaces_bridge_edit.php | ||
+++ b/src/usr/local/www/interfaces_bridge_edit.php | ||
@@ -356,10 +356,19 @@ if ($_POST['save']) { | ||
$bridge['autoptp'] = implode(',', $_POST['autoptp']); | ||
} | ||
|
||
- $bridge['bridgeif'] = $_POST['bridgeif']; | ||
+ if (empty($_POST['bridgeif']) || | ||
+ preg_match("/^bridge[0-9]+$/", $_POST['bridgeif'])) { | ||
+ /* Attempt initial configuration of the bridge if the | ||
+ * submitted interface is empty or looks like a bridge | ||
+ * interface. */ | ||
+ $bridge['bridgeif'] = $_POST['bridgeif']; | ||
+ interface_bridge_configure($bridge); | ||
+ } else { | ||
+ $input_errors[] = gettext("Invalid bridge interface."); | ||
+ } | ||
|
||
- interface_bridge_configure($bridge); | ||
- if ($bridge['bridgeif'] == "" || !stristr($bridge['bridgeif'], "bridge")) { | ||
+ if (empty($bridge['bridgeif']) || | ||
+ !preg_match("/^bridge[0-9]+$/", $bridge['bridgeif'])) { | ||
$input_errors[] = gettext("Error occurred creating interface, please retry."); | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters