From: Anatol Belski Date: Tue, 24 Oct 2017 11:59:18 +0000 (+0200) Subject: Fixed bug #72535 arcfour encryption stream filter crashes php X-Git-Tag: php-5.6.32~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37acebcc8cdc94699d6288f2341aa1b482474ea5;p=php Fixed bug #72535 arcfour encryption stream filter crashes php --- diff --git a/ext/mcrypt/mcrypt_filter.c b/ext/mcrypt/mcrypt_filter.c index cfaf25c3ab..fcb5064713 100644 --- a/ext/mcrypt/mcrypt_filter.c +++ b/ext/mcrypt/mcrypt_filter.c @@ -89,7 +89,7 @@ static php_stream_filter_status_t php_mcrypt_filter( php_stream_bucket_delref(bucket TSRMLS_CC); } else { /* Stream cipher */ - php_stream_bucket_make_writeable(bucket TSRMLS_CC); + bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC); if (data->encrypt) { mcrypt_generic(data->module, bucket->buf, bucket->buflen); } else { diff --git a/ext/mcrypt/tests/bug72535.phpt b/ext/mcrypt/tests/bug72535.phpt new file mode 100644 index 0000000000..9e6d8333f9 --- /dev/null +++ b/ext/mcrypt/tests/bug72535.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #72535 arcfour encryption stream filter crashes php +--SKIPIF-- + +--FILE-- + $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==