php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77207 openssl_pkey_get_private didn't free memory
Submitted: 2018-11-27 09:53 UTC Modified: 2021-06-13 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sagaxu at qq dot com Assigned: cmb (profile)
Status: No Feedback Package: OpenSSL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sagaxu at qq dot com
New email:
PHP Version: OS:

 

 [2018-11-27 09:53 UTC] sagaxu at qq dot com
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+nn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r
07z2gQKBgQCtukjBH1l/zHyV3acr5zXhY416wvEMh3zfYWQYYwoUACOaUTlO4Fqz
EsmRtC76Nc3zpLz3/dhMn9ywz7+HJqZs7hNTvU2vxEBAaCFYyzljaJA1EjIKQAdr
jUfQ5aNvrj5lVBJ+iHbV5O/ktFHLcM8eVurZpDirshS2DFMkcrcLHg==
-----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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-02 11:09 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-06-02 11:09 UTC] cmb@php.net
I cannot reproduce this with current PHP-7.4.  Is this still an
issue for you with any of the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-06-13 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC