|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-17 17:11 UTC] mangirdas at impresspages dot org
Description:
------------
This function throws a segmentation fault:
openssl_decrypt ('kzo w2RMExUTYQXW2Xzxmg==', 'aes-128-cbc', 'pass', $rawOutput,
'pass');
Test script:
---------------
<?php
openssl_decrypt ('kzo w2RMExUTYQXW2Xzxmg==', 'aes-128-cbc', 'pass', $rawOutput,
'pass');
Expected result:
----------------
FALSE, because encrypted string is incorrect.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 11:00:02 2025 UTC |
Confirmed It would help to mention that this gives this warning: Warning: openssl_decrypt(): IV passed is only 4 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 which is probably the cause here. The buffer we pass in is not large enough to fit the IV. A quick hack which fixes the segfault: --- ext/openssl/openssl.c (revision 323261) +++ ext/openssl/openssl.c (working copy) @@ -4819,7 +4819,7 @@ free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type) TSRMLS_CC); outlen = data_len + EVP_CIPHER_block_size(cipher_type); - outbuf = emalloc(outlen + 1); + outbuf = emalloc(outlen + 16); EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL); if (password_len > keylen) { but it obviously isn't the right solution.