[shibboleth-sp2] 05/19: SSPCPP-711 - Bracket some regexp.match() statements with a try/catch

Ferenc Wágner wferi at moszumanska.debian.org
Wed Nov 15 22:56:45 UTC 2017


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

wferi pushed a commit to branch maint-2.6
in repository shibboleth-sp2.

commit b673bb01f2a3bb61a834d69e450c7538b4f8ebfe
Author: Scott Cantor <cantor.2 at osu.edu>
Date:   Mon Nov 13 11:41:34 2017 -0500

    SSPCPP-711 - Bracket some regexp.match() statements with a try/catch
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-711
---
 shibsp/impl/XMLRequestMapper.cpp | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index d32eb97..cb8ec48 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -413,9 +413,14 @@ const Override* Override::locate(const HTTPRequest& request) const
             path2 = path2.substr(0, sep);
 
         for (vector< pair< boost::shared_ptr<RegularExpression>,boost::shared_ptr<Override> > >::const_iterator re = o->m_regexps.begin(); re != o->m_regexps.end(); ++re) {
-            if (re->first->matches(path2.c_str())) {
-                o = re->second.get();
-                break;
+            try {
+                if (re->first->matches(path2.c_str())) {
+                    o = re->second.get();
+                    break;
+                }
+            } catch (XMLException& ex) {
+                auto_ptr_char tmp(ex.getMessage());
+                throw ConfigurationException("Caught exception while matching PathRegex : $1", params(1, tmp.get()));
             }
         }
     }
@@ -433,10 +438,15 @@ const Override* Override::locate(const HTTPRequest& request) const
                     if (q->get<1>()) {
                         // We have to match one of the values.
                         while (vals.first != vals.second) {
-                            if (q->get<1>()->matches(vals.first->second)) {
-                                o = q->get<2>().get();
-                                descended = true;
-                                break;
+                            try{
+                                if (q->get<1>()->matches(vals.first->second)) {
+                                    o = q->get<2>().get();
+                                    descended = true;
+                                    break;
+                                }
+                            } catch (XMLException& ex) {
+                                auto_ptr_char tmp(ex.getMessage());
+                                throw ConfigurationException("Caught exception while matching Query regular expression : $1", params(1, tmp.get()));
                             }
                             ++vals.first;
                         }
@@ -619,8 +629,14 @@ const Override* XMLRequestMapperImpl::findOverride(const char* vhost, const HTTP
         o = i->second.get();
     else {
         for (vector< pair< boost::shared_ptr<RegularExpression>,boost::shared_ptr<Override> > >::const_iterator re = m_regexps.begin(); !o && re != m_regexps.end(); ++re) {
-            if (re->first->matches(vhost))
-                o=re->second.get();
+            try{
+                if (re->first->matches(vhost))
+                    o=re->second.get();
+            } catch (XMLException& ex) {
+                auto_ptr_char tmp(ex.getMessage());
+                throw ConfigurationException("Caught exception while matching HostRegex : $1", params(1, tmp.get()));
+            }
+
         }
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list