Skip to content

Commit 29d79dc

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 09ac6eb + 4feddd5 commit 29d79dc

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

ext/openssl/openssl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6546,7 +6546,10 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
65466546
return FAILURE;
65476547
}
65486548
if (mode->is_single_run_aead && enc) {
6549-
EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL);
6549+
if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) {
6550+
php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed");
6551+
return FAILURE;
6552+
}
65506553
} else if (!enc && tag && tag_len > 0) {
65516554
if (!mode->is_aead) {
65526555
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");

ext/openssl/tests/openssl_encrypt_ccm.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ foreach ($tests as $idx => $test) {
2424
// Empty IV error
2525
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
2626

27-
// Test setting different IV length and unlimeted tag
28-
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 1024));
27+
// Test setting different IV length and tag length
28+
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 14));
2929
var_dump(strlen($tag));
30+
31+
// Test setting invalid tag length
32+
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 16), $tag, '', 1024));
3033
?>
3134
--EXPECTF--
3235
TEST 0
@@ -36,4 +39,7 @@ bool(true)
3639
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
3740
bool(false)
3841
string(8) "p/lvgA=="
39-
int(1024)
42+
int(14)
43+
44+
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
45+
bool(false)

0 commit comments

Comments
 (0)