Bug #54061 [Opn->Csd]: Memory leaks when openssl_encrypt called
| From: | pajoye@php.net | Date: | Mon, 21 Feb 2011 14:45:55 +0000 |
| Subject: | Bug #54061 [Opn->Csd]: Memory leaks when openssl_encrypt called | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158931@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54061&edit=1
ID: 54061
Updated by: pajoye@php.net
Reported by: dovbysh at gmail dot com
Summary: Memory leaks when openssl_encrypt called
-Status: Open
+Status: Closed
Type: Bug
Package: OpenSSL related
Operating System: Linux, Any
PHP Version: 5.3SVN-2011-02-21 (snap)
-Assigned To:
+Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
Fixed by http://svn.php.net/viewvc?view=revision&revision=308535
Previous Comments:
------------------------------------------------------------------------
[2011-02-21 12:59:10] dovbysh at gmail dot com
Description:
------------
Related bug #54060, http://bugs.php.net/bug.php?id=54060
Memory leaks when I call openssl_decrypt. Test script shows that. I've
watch at ext/openssl/openssl.c and according to
http://www.openssl.org/docs/crypto/EVP_EncryptInit.html
(see example at
the bottom) you should free cipher_ctx.
<?php
$data = "jfdslkjvflsdkjvlkfjvlkjfvlkdm,4w 043920r 9234r 32904r 09243
r7-89437 r892374 r894372 r894 7289r7 f frwerfh i iurf iuryw uyrfouiwy
ruy 972439 8478942 yrhfjkdhls";
$pass = "r23498rui324hjbnkj";
$maxi = 200000;
$t = microtime(1);
for ($i=0;$i<$maxi; $i++){
$cr = openssl_encrypt($data.$i, 'des3', $pass, false, '1qazxsw2');
$dcr = openssl_decrypt($cr, 'des3', $pass, false, '1qazxsw2');
if ($dcr != $data.$i){
print "at step $i decryption failed\n";
}
}
$t = microtime(1)-$t;
print "mode: openssl_encrypt ($maxi) tests takes ".$t."secs
".($maxi/$t)."#/sec \n";
?>
fixes by add this code at line 4818 at the end of openssl_decrypt:
EVP_CIPHER_CTX_cleanup(&cipher_ctx);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54061&edit=1