Bug #77207 [NEW]: openssl_pkey_get_private didn't free memory
| From: | sagaxu at qq dot com | Date: | Tue, 27 Nov 2018 09:53:09 +0000 |
| Subject: | Bug #77207 [NEW]: openssl_pkey_get_private didn't free memory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-218155@lists.php.net to get a copy of this message | ||
From: sagaxu at qq dot com
Operating system:
PHP version: Irrelevant
Package: OpenSSL related
Bug Type: Bug
Bug description:openssl_pkey_get_private didn't free memory
Description:
------------
$ php -v
PHP 7.2.11-3build2 (cli) (built: Nov 26 2018 13:08:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.11-3build2, Copyright (c) 1999-2018, by Zend
Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
PHP 7.1.X and 7.2.X both affected.
Test script:
---------------
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'stderr');
$pk = '-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAokB9srofHWSRuv0x679iYftvS0WBrTS0FvK/yzpdAodcNm5S
SQ8YJqRv5o/YE/i+d49zMM92/Q7hTVnuaEpmYzsX34PvOKYW7LEuTYpa/QRQvcUJ
p/vZ9sR3s7c/FoWrdzIl7kx/WYF53gEvQuHM/qbmRczZ6mdtGN01cYYPVm+oQaPQ
E6r3aQzf+R4XkMFTfbT9iz8NWnPuo+GmGsVqGV1e8tALzybeWqQAwzf5g5sLIGb8
MXPx0dipM98hkw3XKO+sVwxYY5vVnskq05Jw74zZkr9k9vWZC7S80YJkrIzzZaJ4
yPtAdKCS1Nk+nnqVKA4POIZN2cEmO7lrUfb3TwIDAQABAoIBAH1krABpuUxFAh9q
OJ+CfG1PHXcl049h0OB/YNyWUXV32TszzaIq6TZMFTMx7gOZVNIf6h1J6SKv0k2u
eALfpPuBmvSiCUpVihgI4skIaUNrh17yHYFWsd/1fLFGqJomWhq3hfsB4dXxq5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shS2DFMkcrcLHg==
-----END RSA PRIVATE KEY-----';
for ($i=0; $i<10; $i++) {
for ($j=0; $j<10000; $j++) {
$key = openssl_pkey_get_private($pk);
openssl_pkey_free($key);
}
echo memory_get_usage() . "\n";
}
Expected result:
----------------
223840
223880
223880
223880
223880
223880
223880
223880
223880
223880
Actual result:
--------------
1167336
1931656
2171656
3460256
3700256
3940256
6277408
6517408
6757408
6997408
--
Edit bug report at https://bugs.php.net/bug.php?id=77207&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77207&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77207&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77207&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77207&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77207&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77207&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77207&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77207&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77207&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77207&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77207&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77207&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77207&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77207&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77207&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77207&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77207&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77207&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77207&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77207&r=mysqlcfg