summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/exec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index aedfa94ce2..32e0f693ea 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -271,6 +271,11 @@ PHPAPI char *php_escape_shell_cmd(char *str)
cmd = safe_emalloc(2, l, 1);
for (x = 0, y = 0; x < l; x++) {
+ /* skip non-valid multibyte characters */
+ if (php_mblen(str + x, (l - x)) < 0) {
+ continue;
+ }
+
switch (str[x]) {
case '"':
case '\'':