Skip to content

Commit dd46a0b

Browse files
author
Andrew Thompson
committed
If the certificate arrays happen to be sparsely indexed this can blow out the memory.
One scenario is indexing the certificates based on the short hash, php will magically expand this hex string in to a very large index number. eg, 'd5c242d7' => '-----BEGIN CERTIFICATE-----...' will cause loop to go from i=0 to i=3586278103
1 parent b41f731 commit dd46a0b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/Saml2/Settings.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,13 +941,13 @@ public function formatIdPCertMulti()
941941
{
942942
if (isset($this->_idp['x509certMulti'])) {
943943
if (isset($this->_idp['x509certMulti']['signing'])) {
944-
for ($i=0; $i < count($this->_idp['x509certMulti']['signing']); $i++) {
945-
$this->_idp['x509certMulti']['signing'][$i] = OneLogin_Saml2_Utils::formatCert($this->_idp['x509certMulti']['signing'][$i]);
944+
foreach($this->_idp['x509certMulti']['signing'] as $i => $cert) {
945+
$this->_idp['x509certMulti']['signing'][$i] = OneLogin_Saml2_Utils::formatCert($cert);
946946
}
947947
}
948948
if (isset($this->_idp['x509certMulti']['encryption'])) {
949-
for ($i=0; $i < count($this->_idp['x509certMulti']['encryption']); $i++) {
950-
$this->_idp['x509certMulti']['encryption'][$i] = OneLogin_Saml2_Utils::formatCert($this->_idp['x509certMulti']['encryption'][$i]);
949+
foreach($this->_idp['x509certMulti']['encryption'] as $i => $cert) {
950+
$this->_idp['x509certMulti']['encryption'][$i] = OneLogin_Saml2_Utils::formatCert($cert);
951951
}
952952
}
953953
}

0 commit comments

Comments
 (0)