com php-src: Fixed bug #71039 exec functions ignore length but look for NULL termination: ext/standard/exec.c ext/standard/tests/genera
l_functions/escapeshellarg_bug71039.phpt ext/ standard/tests/general_functions/escapeshellcmd_bug71 039.phpt

From: Date: Tue, 12 Jan 2016 13:57:22 +0000
Subject: com php-src: Fixed bug #71039 exec functions ignore length but look for NULL termination: ext/standard/exec.c ext/standard/tests/genera
l_functions/escapeshellarg_bug71039.phpt ext/ standard/tests/general_functions/escapeshellcmd_bug71 039.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90884@lists.php.net to get a copy of this message
Commit: c527549e899bf211aac7d8ab5ceb1bdfedf07f14 Author: Anatol Belski <ab@php.net> Tue, 12 Jan 2016 14:57:22 +0100 Parents: 22a5ccab720fdff4bb56f2af6efe9ca7d3045a48 Branches: PHP-7.0 PHP-7.0.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c527549e899bf211aac7d8ab5ceb1bdfedf07f14 Log: Fixed bug #71039 exec functions ignore length but look for NULL termination Bugs: https://bugs.php.net/71039 Changed paths: M ext/standard/exec.c A ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt A ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt Diff: diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 747f765..29024f6 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -467,6 +467,10 @@ PHP_FUNCTION(escapeshellcmd) } if (command_len) { + if (command_len != strlen(command)) { + php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes"); + return; + } RETVAL_STR(php_escape_shell_cmd(command)); } else { RETVAL_EMPTY_STRING(); @@ -486,6 +490,10 @@ PHP_FUNCTION(escapeshellarg) } if (argument) { + if (argument_len != strlen(argument)) { + php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes"); + return; + } RETVAL_STR(php_escape_shell_arg(argument)); } } diff --git a/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt new file mode 100644 index 0000000..cbb3f6f --- /dev/null +++ b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt @@ -0,0 +1,10 @@ +--TEST-- +Test escapeshellarg() string with \0 bytes +--FILE-- +<?php +escapeshellarg("hello\0world"); + +?> +===DONE=== +--EXPECTF-- +Fatal error: escapeshellarg(): Input string contains NULL bytes in %s on line %d diff --git a/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt new file mode 100644 index 0000000..0a4d7ea --- /dev/null +++ b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt @@ -0,0 +1,10 @@ +--TEST-- +Test escapeshellcmd() string with \0 bytes +--FILE-- +<?php +escapeshellcmd("hello\0world"); + +?> +===DONE=== +--EXPECTF-- +Fatal error: escapeshellcmd(): Input string contains NULL bytes in %s on line %d

« previous php.cvs (#90884) next »