summaryrefslogtreecommitdiffstats
path: root/php-bug79330.patch
blob: a041f0fb076faf7ad6f9e909e40886c9e0244d82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From d35cb9cdee586a9668ca1d9a72ffdb4f0902b2ba Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Mon, 13 Apr 2020 21:00:44 -0700
Subject: [PATCH] Fix bug #79330 - make all execution modes consistent in
 rejecting \0

(cherry picked from commit 14fcc813948254b84f382ff537247d8a7e5e0e62)
---
 ext/standard/exec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index d6f0cbfeb2..e486f52a3d 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -524,6 +524,15 @@ PHP_FUNCTION(shell_exec)
 		return;
 	}
 
+	if (!command_len) {
+		php_error_docref(NULL, E_WARNING, "Cannot execute a blank command");
+		RETURN_FALSE;
+	}
+	if (strlen(command) != command_len) {
+		php_error_docref(NULL, E_WARNING, "NULL byte detected. Possible attack");
+		RETURN_FALSE;
+	}
+
 #ifdef PHP_WIN32
 	if ((in=VCWD_POPEN(command, "rt"))==NULL) {
 #else