[cpp-sp] 05/09: SSPCPP-711 - Bracket some regexp.match() statements with a try/catch
Scott Cantor
cantor.2 at osu.edu
Mon Nov 13 11:46:29 EST 2017
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-2.6
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=b673bb01f2a3bb61a834d69e450c7538b4f8ebfe
commit b673bb01f2a3bb61a834d69e450c7538b4f8ebfe
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: 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()));
+ }
+
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list