xref: /PHP-7.0/ext/mcrypt/tests/bug72535.phpt (revision 37acebcc)
1--TEST--
2Bug #72535 arcfour encryption stream filter crashes php
3--SKIPIF--
4<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
5--FILE--
6<?php
7$passphrase = 'My secret';
8$plaintext = 'Secret secret secret data';
9
10$iv = substr(md5('iv' . $passphrase, true), 0, 8);
11$key = substr(md5('pass1' . $passphrase, true) .
12	              md5('pass2' . $passphrase, true), 0, 24);
13$opts = array('iv' => $iv, 'key' => $key, 'mode' => 'stream');
14
15$expected = substr($plaintext . $plaintext, 0, 48);
16
17$fp = fopen('php://memory', 'wb+');
18stream_filter_append($fp, 'mcrypt.arcfour', STREAM_FILTER_WRITE, $opts);
19fwrite($fp, $plaintext);
20?>
21==NOCRASH==
22--EXPECT--
23==NOCRASH==
24