1From d3880d9d3ba795138444da83f1153c3c3ac27640 Mon Sep 17 00:00:00 2001
2From: Michael Larabel <michael@phoronix.com>
3Date: Sat, 23 Jul 2022 07:32:43 -0500
4Subject: [PATCH] phoromatic: Explicitly check both $_GET abd $_POST in
5 phoromatic_quit_if_invalid_input_found()
6
7Fixes: https://github.com/phoronix-test-suite/phoronix-test-suite/issues/650#issuecomment-1193116678
8
9Upstream-Status: Backport
10CVE: CVE-2022-40704
11
12Reference to upstream patch:
13https://github.com/phoronix-test-suite/phoronix-test-suite/commit/d3880d9d3ba795138444da83f1153c3c3ac27640
14
15Signed-off-by: Li Wang <li.wang@windriver.com>
16---
17 pts-core/phoromatic/phoromatic_functions.php | 15 +++++++++++++--
18 1 file changed, 13 insertions(+), 2 deletions(-)
19
20diff --git a/pts-core/phoromatic/phoromatic_functions.php b/pts-core/phoromatic/phoromatic_functions.php
21index 74ccc5444c..c2313dcdea 100644
22--- a/pts-core/phoromatic/phoromatic_functions.php
23+++ b/pts-core/phoromatic/phoromatic_functions.php
24@@ -37,9 +37,20 @@ function phoromatic_quit_if_invalid_input_found($input_keys = null)
25 	{
26 		foreach($input_keys as $key)
27 		{
28-			if(isset($_REQUEST[$key]) && !empty($_REQUEST[$key]))
29+			if(isset($_GET[$key]) && !empty($_GET[$key]))
30 			{
31-				foreach(pts_arrays::to_array($_REQUEST[$key]) as $val_to_check)
32+				foreach(pts_arrays::to_array($_GET[$key]) as $val_to_check)
33+				{
34+					if(stripos($val_to_check, $invalid_string) !== false)
35+					{
36+						echo '<strong>Exited due to invalid input ( ' . $invalid_string . ') attempted:</strong> ' . htmlspecialchars($val_to_check);
37+						exit;
38+					}
39+				}
40+			}
41+			if(isset($_POST[$key]) && !empty($_POST[$key]))
42+			{
43+				foreach(pts_arrays::to_array($_POST[$key]) as $val_to_check)
44 				{
45 					if(stripos($val_to_check, $invalid_string) !== false)
46 					{
47