Skip to content

Commit 2425894

Browse files
smalyshevcmb69
authored andcommitted
Fix bug #79330 - make all execution modes consistent in rejecting \0
(cherry picked from commit 14fcc81)
1 parent ad5b00a commit 2425894

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PHP NEWS
3535
(cmb)
3636

3737
- Standard:
38+
. Fixed bug #79330 (shell_exec() silently truncates after a null byte). (stas)
3839
. Fixed bug #79410 (system() swallows last chunk if it is exactly 4095 bytes
3940
without newline). (Christian Schneider)
4041

ext/standard/exec.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,15 @@ PHP_FUNCTION(shell_exec)
537537
Z_PARAM_STRING(command, command_len)
538538
ZEND_PARSE_PARAMETERS_END();
539539

540+
if (!command_len) {
541+
php_error_docref(NULL, E_WARNING, "Cannot execute a blank command");
542+
RETURN_FALSE;
543+
}
544+
if (strlen(command) != command_len) {
545+
php_error_docref(NULL, E_WARNING, "NULL byte detected. Possible attack");
546+
RETURN_FALSE;
547+
}
548+
540549
#ifdef PHP_WIN32
541550
if ((in=VCWD_POPEN(command, "rt"))==NULL) {
542551
#else

0 commit comments

Comments
 (0)