Skip to content

Commit c0eecd5

Browse files
committed
fix test attempt
1 parent 6501136 commit c0eecd5

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

ext/openssl/openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7947,7 +7947,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
79477947
}
79487948

79497949
#ifdef EVP_CIPH_WRAP_MODE
7950-
if ((EVP_CIPHER_flags(cipher_type) & EVP_CIPH_MODE) == EVP_CIPH_WRAP_MODE) {
7950+
if ((EVP_CIPHER_mode(cipher_type)) == EVP_CIPH_WRAP_MODE) {
79517951
/*
79527952
* RFC 5649 wrap-with-padding rounds the input up to the block size
79537953
* and prepends an integrity block, we reserve one extra block.

ext/openssl/tests/gh22186.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ GH-22186 (Heap buffer overflow in openssl_encrypt with AES-WRAP-PAD)
44
openssl
55
--SKIPIF--
66
<?php
7-
if (!in_array('aes-128-wrap-pad', openssl_get_cipher_methods(), true)) {
8-
die('skip aes-128-wrap-pad not available');
7+
/* openssl_get_cipher_methods() enumerates provider ciphers, but openssl_encrypt()
8+
* resolves names via the legacy EVP_get_cipherbyname(), so on some builds the
9+
* cipher is listed yet not usable. Probe the actual call path instead. */
10+
if (!@openssl_encrypt("test", "aes-128-wrap-pad", str_repeat("k", 16),
11+
OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY, str_repeat("\0", 4))) {
12+
die('skip aes-128-wrap-pad not usable on this OpenSSL build');
913
}
1014
?>
1115
--FILE--

0 commit comments

Comments
 (0)