[cpp-sp] branch main updated: Catch load exceptions in RequestMapper.

Scott Cantor cantor.2 at osu.edu
Mon Dec 16 15:54:55 UTC 2024


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=c4796f7a9b53f3b1d5f2ac716a715ea06be4943b

The following commit(s) were added to refs/heads/main by this push:
     new c4796f7a Catch load exceptions in RequestMapper.
c4796f7a is described below

commit c4796f7a9b53f3b1d5f2ac716a715ea06be4943b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Dec 16 10:54:50 2024 -0500

    Catch load exceptions in RequestMapper.
---
 shibsp/impl/XMLRequestMapper.cpp | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index 1908c703..6bc52407 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -647,21 +647,27 @@ pair<bool,ptree*> XMLRequestMapper::load() noexcept
         return raw;
     }
 
-    // If we own it, wrap it.
-    unique_ptr<ptree> treejanitor(raw.first ? raw.second : nullptr);
+    try {
+        // If we own it, wrap it.
+        unique_ptr<ptree> treejanitor(raw.first ? raw.second : nullptr);
 
-    unique_ptr<XMLRequestMapperImpl> impl(new XMLRequestMapperImpl(*raw.second, m_log));
+        unique_ptr<XMLRequestMapperImpl> impl(new XMLRequestMapperImpl(*raw.second, m_log));
 
-    // If we held the document, transfer it to the impl. If we didn't, it's a no-op.
-    impl->setTree(treejanitor.release());
+        // If we held the document, transfer it to the impl. If we didn't, it's a no-op.
+        impl->setTree(treejanitor.release());
 
     // Perform the swap inside a lock.
 #ifdef HAVE_CXX14
-    unique_lock<ReloadableXMLFile> locker(*this);
+        unique_lock<ReloadableXMLFile> locker(*this);
 #endif
-    m_impl.swap(impl);
-
-    return make_pair(false,raw.second);
+        m_impl.swap(impl);
+        
+        return make_pair(false, raw.second);
+    }
+    catch (exception& e) {
+        m_log.error("exception loading RequestMapper: %s", e.what());
+        return make_pair(false, nullptr);
+    }
 }
 
 RequestMapper::Settings XMLRequestMapper::getSettings(const HTTPRequest& request) const

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


More information about the commits mailing list