Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7457,18 +7457,20 @@ PHP_FUNCTION(openssl_open)
cipher = EVP_get_cipherbyname(method);
if (!cipher) {
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
RETURN_FALSE;
RETVAL_FALSE;
goto out_pkey;
}

cipher_iv_len = EVP_CIPHER_iv_length(cipher);
if (cipher_iv_len > 0) {
if (!iv) {
zend_argument_value_error(6, "cannot be null for the chosen cipher algorithm");
RETURN_THROWS();
goto out_pkey;
}
if ((size_t)cipher_iv_len != iv_len) {
php_error_docref(NULL, E_WARNING, "IV length is invalid");
RETURN_FALSE;
RETVAL_FALSE;
goto out_pkey;
}
iv_buf = (unsigned char *)iv;
} else {
Expand All @@ -7490,8 +7492,9 @@ PHP_FUNCTION(openssl_open)
}

efree(buf);
EVP_PKEY_free(pkey);
EVP_CIPHER_CTX_free(ctx);
out_pkey:
EVP_PKEY_free(pkey);
}
/* }}} */

Expand Down
Loading