[cpp-sp] branch main updated: SSPCPP-924 - Crash in SAML logout handler when no metadata present

Scott Cantor cantor.2 at osu.edu
Wed Mar 31 12:58:05 UTC 2021


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=256a6af782cc2f0e554f4aff6a2b71a7c88206e6

The following commit(s) were added to refs/heads/main by this push:
       new  256a6af7  SSPCPP-924 - Crash in SAML logout handler when no metadata present
256a6af7 is described below

commit 256a6af782cc2f0e554f4aff6a2b71a7c88206e6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 31 08:57:58 2021 -0400

    SSPCPP-924 - Crash in SAML logout handler when no metadata present
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-924
---
 shibsp/handler/impl/SAML2Logout.cpp     |  9 +++++----
 shibsp/handler/impl/SAML2NameIDMgmt.cpp | 10 ++++++----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/shibsp/handler/impl/SAML2Logout.cpp b/shibsp/handler/impl/SAML2Logout.cpp
index f07eef17..f9d3abd3 100644
--- a/shibsp/handler/impl/SAML2Logout.cpp
+++ b/shibsp/handler/impl/SAML2Logout.cpp
@@ -646,8 +646,8 @@ pair<bool,long> SAML2Logout::sendResponse(
             }
         }
         if (!ep || !encoder) {
-            auto_ptr_char id(dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID());
-            m_log.error("unable to locate compatible SLO service for provider (%s)", id.get());
+            auto_ptr_char id(role ? dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID() : nullptr);
+            m_log.error("unable to locate compatible SLO service for provider (%s)", id.get() ? id.get() : "unknown");
             MetadataException ex("Unable to locate endpoint at IdP ($entityID) to send LogoutResponse.");
             annotateException(&ex, role);   // throws it
         }
@@ -667,7 +667,8 @@ pair<bool,long> SAML2Logout::sendResponse(
     }
     Issuer* issuer = IssuerBuilder::buildIssuer();
     logout->setIssuer(issuer);
-    issuer->setName(application.getRelyingParty(dynamic_cast<EntityDescriptor*>(role->getParent()))->getXMLString("entityID").second);
+    issuer->setName(application.getRelyingParty(role ? dynamic_cast<EntityDescriptor*>(role->getParent()) :
+            nullptr)->getXMLString("entityID").second);
     fillStatus(*logout, code, subcode, msg);
     XMLCh* msgid = SAMLConfig::getConfig().generateIdentifier();
     logout->setID(msgid);
@@ -675,7 +676,7 @@ pair<bool,long> SAML2Logout::sendResponse(
     logout->setIssueInstant(time(nullptr));
 
     if (logoutEvent) {
-        logoutEvent->m_peer = dynamic_cast<EntityDescriptor*>(role->getParent());
+        logoutEvent->m_peer = role ? dynamic_cast<EntityDescriptor*>(role->getParent()) : nullptr;
         logoutEvent->m_saml2Response = logout.get();
         application.getServiceProvider().getTransactionLog()->write(*logoutEvent);
     }
diff --git a/shibsp/handler/impl/SAML2NameIDMgmt.cpp b/shibsp/handler/impl/SAML2NameIDMgmt.cpp
index ae93adf9..2301debe 100644
--- a/shibsp/handler/impl/SAML2NameIDMgmt.cpp
+++ b/shibsp/handler/impl/SAML2NameIDMgmt.cpp
@@ -286,7 +286,8 @@ pair<bool,long> SAML2NameIDMgmt::doRequest(const Application& application, HTTPR
                 );
         }
 
-        EntityDescriptor* entity = policy->getIssuerMetadata() ? dynamic_cast<EntityDescriptor*>(policy->getIssuerMetadata()->getParent()) : nullptr;
+        EntityDescriptor* entity = policy->getIssuerMetadata() ?
+                dynamic_cast<EntityDescriptor*>(policy->getIssuerMetadata()->getParent()) : nullptr;
 
         scoped_ptr<XMLObject> decryptedID;
         NameID* nameid = mgmtRequest->getNameID();
@@ -485,8 +486,8 @@ pair<bool,long> SAML2NameIDMgmt::sendResponse(
             }
         }
         if (!ep || !encoder) {
-            auto_ptr_char id(dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID());
-            m_log.error("unable to locate compatible NIM service for provider (%s)", id.get());
+            auto_ptr_char id(role ? dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID() : nullptr);
+            m_log.error("unable to locate compatible NIM service for provider (%s)", id.get() ? id.get() : "unknown");
             MetadataException ex("Unable to locate endpoint at IdP ($entityID) to send ManageNameIDResponse.");
             annotateException(&ex, role);   // throws it
         }
@@ -506,7 +507,8 @@ pair<bool,long> SAML2NameIDMgmt::sendResponse(
     }
     Issuer* issuer = IssuerBuilder::buildIssuer();
     nim->setIssuer(issuer);
-    issuer->setName(application.getRelyingParty(dynamic_cast<EntityDescriptor*>(role->getParent()))->getXMLString("entityID").second);
+    issuer->setName(application.getRelyingParty(role ? dynamic_cast<EntityDescriptor*>(role->getParent()) :
+            nullptr)->getXMLString("entityID").second);
     fillStatus(*nim, code, subcode, msg);
 
     auto_ptr_char dest(nim->getDestination());

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list