Skip to content

Commit fe1933a

Browse files
committed
Fixed bug #70625
1 parent 6f895a2 commit fe1933a

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
- Date:
66
. Fixed bug #70619 (DateTimeImmutable segfault). (Laruence)
77

8+
- Mcrypt:
9+
. Fixed bug #70625 (mcrypt_encrypt() won't return data when no IV was
10+
specified under RC4). (Nikita)
11+
812
- Mysqlnd:
913
. Fixed bug #70384 (mysqli_real_query():Unknown type 245 sent by the server).
1014
(Andrey)

‎ext/mcrypt/mcrypt.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,10 @@ static int php_mcrypt_ensure_valid_iv(MCRYPT td, const char *iv, int iv_size TSR
12371237
{
12381238
if (mcrypt_enc_mode_has_iv(td) == 1) {
12391239
int expected_iv_size = mcrypt_enc_get_iv_size(td);
1240+
if (expected_iv_size == 0) {
1241+
/* Algorithm does not use IV, even though mode supports it */
1242+
return SUCCESS;
1243+
}
12401244

12411245
if (!iv) {
12421246
php_error_docref(NULL TSRMLS_CC, E_WARNING,

‎ext/mcrypt/tests/bug70625.phpt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #70625: mcrypt_encrypt() : won't return data when no IV was specified under RC4
3+
--SKIPIF--
4+
<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
$key = 'secretkey';
9+
$ciphertext = mcrypt_encrypt(MCRYPT_ARCFOUR, $key, 'payload', MCRYPT_MODE_STREAM);
10+
var_dump(bin2hex($ciphertext));
11+
$plaintext = mcrypt_decrypt(MCRYPT_ARCFOUR, $key, $ciphertext, MCRYPT_MODE_STREAM);
12+
var_dump($plaintext);
13+
14+
?>
15+
--EXPECT--
16+
string(14) "d5c9a57023d0f1"
17+
string(7) "payload"

0 commit comments

Comments
 (0)