Skip to content

Commit

Permalink
Fixed bug #22414 and added a test case for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Alshanetsky committed Feb 25, 2003
1 parent 400f466 commit f29964e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/standard/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC)
} else {
size_t b;

while ((b = fread(buf, buflen, 1, fp)) > 0) {
while((b = php_stream_read(stream, buf, EXEC_INPUT_BUF)) > 0) {
if (output) {
PHPWRITE(buf, b);
}
Expand Down
37 changes: 37 additions & 0 deletions ext/standard/tests/file/bug22414.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
Bug #22414: passthru() does not read data correctly
--SKIPIF--
<?php
if (empty(@shell_exec("which cat")) {
dir('skip cat binary needed for this test is not avaliable');
}
?>
--POST--
--GET--
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
$pwd = realpath(dirname(__FILE__));

/* Regular Data Test */
passthru($php . ' -r " echo \"HELLO\"; "');

echo "\n";

/* Binary Data Test */
@unlink($pwd . '/passthru_test');

$cmd = $php . ' -r \' passthru("cat ' . $php . '"); \' > ' . $pwd . '/passthru_test';
exec($cmd);

if (md5_file($php) == md5_file($pwd . '/passthru_test')) {
echo "Works\n";
} else {
echo "Does not work\n";
}

@unlink($pwd . '/passthru_test');
?>
--EXPECT--
HELLO
Works

0 comments on commit f29964e

Please sign in to comment.