Bug #75363 [NEW]: openssl_x509_parse leaks memory
| From: | kelunik@php.net | Date: | Thu, 12 Oct 2017 08:21:09 +0000 |
| Subject: | Bug #75363 [NEW]: openssl_x509_parse leaks memory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211636@lists.php.net to get a copy of this message | ||
From: kelunik
Operating system: Linux
PHP version: 7.2.0RC4
Package: OpenSSL related
Bug Type: Bug
Bug description:openssl_x509_parse leaks memory
Description:
------------
openssl_x509_parse leaks memory, which is never freed again. Test
certificate is the Let's Encrypt root certificate:
https://letsencrypt.org/certs/isrgrootx1.pem.txt
https://bugs.php.net/bug.php?id=38261 is already
closed and is only
about invalid certificates.
Test script:
---------------
<?php
$pem = file_get_contents(__DIR__ . "/test.crt");
$i = 0;
while (true) {
$cert = openssl_x509_read($pem);
$info = openssl_x509_parse($cert); // <-- without it, it doesn't
leak
openssl_x509_free($cert);
unset($cert);
if ($i++ % 10000 === 0) {
print PHP_EOL;
print memory_get_usage(true);
print PHP_EOL;
}
}
Expected result:
----------------
2097152
2097152
2097152
2097152
2097152
2097152
2097152
2097152
Actual result:
--------------
2097152
2097152
4194304
4194304
6295552
6295552
6295552
8392704
--
Edit bug report at https://bugs.php.net/bug.php?id=75363&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75363&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75363&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75363&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75363&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75363&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75363&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75363&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75363&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75363&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75363&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75363&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75363&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75363&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75363&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75363&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75363&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75363&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75363&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75363&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75363&r=mysqlcfg