Bug #54061 [NEW]: Memory leaks when openssl_encrypt called
| From: | dovbysh at gmail dot com | Date: | Mon, 21 Feb 2011 11:59:11 +0000 |
| Subject: | Bug #54061 [NEW]: Memory leaks when openssl_encrypt called | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158928@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux, Any
PHP version: 5.3SVN-2011-02-21 (snap)
Package: OpenSSL related
Bug Type: Bug
Bug description:Memory leaks when openssl_encrypt called
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 bug report at http://bugs.php.net/bug.php?id=54061&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54061&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54061&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54061&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54061&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54061&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54061&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54061&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54061&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54061&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54061&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54061&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54061&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54061&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54061&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54061&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54061&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54061&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54061&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54061&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54061&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54061&r=mysqlcfg