Merge branch 'PHP-5.6' into PHP-7.0

* PHP-5.6:
  Fixed bug #72535 arcfour encryption stream filter crashes php
This commit is contained in:
Anatol Belski 2017-10-24 14:04:08 +02:00
commit 968c8fc0d5
2 changed files with 24 additions and 1 deletions

View File

@ -89,7 +89,7 @@ static php_stream_filter_status_t php_mcrypt_filter(
php_stream_bucket_delref(bucket);
} else {
/* Stream cipher */
php_stream_bucket_make_writeable(bucket);
bucket = php_stream_bucket_make_writeable(bucket);
if (data->encrypt) {
mcrypt_generic(data->module, bucket->buf, (int)bucket->buflen);
} else {

View File

@ -0,0 +1,23 @@
--TEST--
Bug #72535 arcfour encryption stream filter crashes php
--SKIPIF--
<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
--FILE--
<?php
$passphrase = 'My secret';
$plaintext = 'Secret secret secret data';
$iv = substr(md5('iv' . $passphrase, true), 0, 8);
$key = substr(md5('pass1' . $passphrase, true) .
md5('pass2' . $passphrase, true), 0, 24);
$opts = array('iv' => $iv, 'key' => $key, 'mode' => 'stream');
$expected = substr($plaintext . $plaintext, 0, 48);
$fp = fopen('php://memory', 'wb+');
stream_filter_append($fp, 'mcrypt.arcfour', STREAM_FILTER_WRITE, $opts);
fwrite($fp, $plaintext);
?>
==NOCRASH==
--EXPECT--
==NOCRASH==