php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65602 PHP 5.5.x stalls: Allowed memory size exhausted. openssl_x509_parse() problem ?
Submitted: 2013-09-01 23:05 UTC Modified: 2019-07-28 04:22 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: mail at tgries dot de Assigned: cmb (profile)
Status: No Feedback Package: OpenSSL related
PHP Version: 5.5.3 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at tgries dot de
New email:
PHP Version: OS:

 

 [2013-09-01 23:05 UTC] mail at tgries dot de
Description:
------------
I noticed now and then the following problem with the new 5.5.2 and 5.5.3 version, which makes the PHP stalling in a short script which uses openssl calls to print server certificates.


PHP Fatal error:  Allowed memory size of 209715200 bytes exhausted (tried to allocate 736849521 bytes) in /srv/www-ssl/scripts/MySimpleCertificateViewer/index.php on line 70

line 70: $certArray = openssl_x509_parse( $cp );

It is currently unclear, why this stall happens, but I want to early report this problem to you developers.

The script is short and available here https://github.com/Wikinaut/MySimpleCertificateViewer .


Test script:
---------------
The script is short and available here https://github.com/Wikinaut/MySimpleCertificateViewer .



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-01 23:08 UTC] mail at tgries dot de
again, just to make it clear: in most of the cases it works. Stalls only now and then. Webserver is Apache, and a restart solves the problem immediately, but this is not a solution.

I suppose, there's a bug in PHP or openssl function.
 [2013-09-01 23:08 UTC] aharvey@php.net
-Package: *General Issues +Package: OpenSSL related
 [2014-01-10 17:35 UTC] nginx-mark at zedwood dot com
The function, openssl_x509_parse() works fine on most certificates.  I think it is getting tripped up on a certain certificate, perhaps the google cert with 100s of subjectAltNames.  Can you post the certificate which triggered the out of memory issue, it will help to research the issue if the behavior is reproducible.
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EwwSjBIBgtghkgBhv1tAQcXATA5MDcGCCsG
AQUFBwIBFitodHRwOi8vY2VydGlmaWNhdGVzLmdvZGFkZHkuY29tL3JlcG9zaXRv
cnkvMHYGCCsGAQUFBwEBBGowaDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZ29k
YWRkeS5jb20vMEAGCCsGAQUFBzAChjRodHRwOi8vY2VydGlmaWNhdGVzLmdvZGFk
ZHkuY29tL3JlcG9zaXRvcnkvZ2RpZzIuY3J0MB8GA1UdIwQYMBaAFEDCvSeOzDSD
MKIz1/tss/C0LIDOMCkGA1UdEQQiMCCCDyoud29yZHByZXNzLm9yZ4INd29yZHBy
ZXNzLm9yZzAdBgNVHQ4EFgQUTqA0/Tj3XxNMtsLjOsC9Kp8eLVgwDQYJKoZIhvcN
AQELBQADggEBACCua5vWQNfTc5aWJu80e6svEmQ7nTv8BeR1jWCUEgPz3EZqRE/P
64lZD+hjU+6sf3KLTqiwvdMef43kcpAHp7w4rUQm0NbW4RP5BcRIjdihfjjLLEfu
sT7KzKWPeb6msjEunKlzEZa9uvmFUz3zCWu9Z0p7QCaudGz9ldJxoOiPxXK2R5qd
T5AJvhH7+WpuxF6RXbjzpkcXOWB2gcidTI/Bw59a90X/ZoJJyaTT2iXP8cYECtwn
Mxo4/P3vJYtE3QFnev7zP+o5CT0gzCmjb9sLOvZE5fRxm+PEefyaFHMebNCElGtC
ZpM3tyeiqyIQK61TeTTSusxnCFjXIDa0tjQ=
-----END CERTIFICATE-----

Just save it in a file (f.ex. test.pem) and call this php code:

<?php
$ssl = openssl_x509_parse(file_get_contents('test.pem'));
print_r($ssl);
?>

Error in the Apache log file is:
[core:notice] [pid 16919] AH00052: child pid 16925 exit signal Segmentation fault (11)

No further debug information availavle, although "LogLevel debug"
 [2019-07-15 17:29 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2019-07-15 17:29 UTC] cmb@php.net
I cannot reproduce this with current PHP-7.2.  Can anybody else
reproduce this with a still supported PHP version[1]?

[1] <https://www.php.net/supported-versions.php>
 [2019-07-28 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: Wed Dec 11 03:01:28 2024 UTC