[PHP-BUG] Bug #74291 [NEW]: openssl_pkcs12_read only returns 1 extracert when the .pfx has multiples

[email protected] ("always666 at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             always666 at gmail dot com
Operating system: irrelevant
PHP version:      7.0.17
Package:          OpenSSL related
Bug Type:         Bug
Bug description:openssl_pkcs12_read only returns 1 extracert when the .pfx has multiples

Description:
------------
latest Fix "#74022 PHP Fast CGI crashes when reading from a pfx file."
broke the export of multiple extracerts.

in git source control theres a bad loop in line 2667
         
            for (i=0; i < sk_X509_num(ca); i++) {
cause in line 2669
            X509* aCA = sk_X509_pop(ca); 
will return and remove the last element from ca so the loop will only
iterate once.
The correct code should be the previous: 
           for (i=0;;i++) {
cause the theres already checks in place to evaluate if the there is no
more certs to process in line 2670:
           if (!aCA) break;

link to git revision for beter understanding.
https://github.com/php/php-src/commit/6fc0ae638acd2a66a4181078f4ac5d789762d9de#diff-69bad938d17f4283faa5f7fea17fa627



-- 
Edit bug report at https://bugs.php.net/bug.php?id=74291&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74291&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74291&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74291&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74291&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74291&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74291&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74291&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74291&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74291&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74291&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74291&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74291&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74291&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74291&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74291&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74291&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74291&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74291&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74291&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74291&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.