[cpp-sp] branch master updated: SSPCPP-739 - AttributeResolver handler should propagate errors to caller

Scott Cantor cantor.2 at osu.edu
Thu Oct 11 20:26:31 EDT 2018


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

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

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

The following commit(s) were added to refs/heads/master by this push:
       new  5e71a5b   SSPCPP-739 - AttributeResolver handler should propagate errors to caller
5e71a5b is described below

commit 5e71a5b5c8f96f4f9684da321f445a41456a0f6a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Oct 11 20:25:39 2018 -0400

    SSPCPP-739 - AttributeResolver handler should propagate errors to caller
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-739
    
    Fix memory leak when resolver throws.
---
 plugins/AttributeResolverHandler.cpp | 54 +++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/plugins/AttributeResolverHandler.cpp b/plugins/AttributeResolverHandler.cpp
index 6c7d1af..d12a38f 100644
--- a/plugins/AttributeResolverHandler.cpp
+++ b/plugins/AttributeResolverHandler.cpp
@@ -369,7 +369,7 @@ ResolutionContext* AttributeResolverHandler::resolveAttributes(
                             *id = mprefix.second + *id;
                     }
                 }
-                catch (std::exception& ex) {
+                catch (const std::exception& ex) {
                     m_log.error("caught exception extracting attributes: %s", ex.what());
                 }
             }
@@ -396,7 +396,7 @@ ResolutionContext* AttributeResolverHandler::resolveAttributes(
             try {
                 filter->filterAttributes(fc, resolvedAttributes);
             }
-            catch (std::exception& ex) {
+            catch (const std::exception& ex) {
                 m_log.error("caught exception filtering attributes: %s", ex.what());
                 m_log.error("dumping extracted attributes due to filtering exception");
                 for_each(resolvedAttributes.begin(), resolvedAttributes.end(), xmltooling::cleanup<shibsp::Attribute>());
@@ -409,27 +409,35 @@ ResolutionContext* AttributeResolverHandler::resolveAttributes(
     if (resolver) {
         m_log.debug("resolving attributes...");
 
-        Locker locker(resolver);
-        auto_ptr<ResolutionContext> ctx(
-            resolver->createResolutionContext(
-                application,
-                &httpRequest,
-                issuer ? dynamic_cast<const saml2md::EntityDescriptor*>(issuer->getParent()) : nullptr,
-                protocol,
-                nameid,
-                nullptr,
-                nullptr,
-                nullptr,
-                &resolvedAttributes
-                )
-            );
-        resolver->resolveAttributes(*ctx);
-        // Copy over any pushed attributes.
-        while (!resolvedAttributes.empty()) {
-            ctx->getResolvedAttributes().push_back(resolvedAttributes.back());
-            resolvedAttributes.pop_back();
+        try {
+			Locker locker(resolver);
+			auto_ptr<ResolutionContext> ctx(
+				resolver->createResolutionContext(
+					application,
+					&httpRequest,
+					issuer ? dynamic_cast<const saml2md::EntityDescriptor*>(issuer->getParent()) : nullptr,
+					protocol,
+					nameid,
+					nullptr,
+					nullptr,
+					nullptr,
+					&resolvedAttributes
+					)
+				);
+			resolver->resolveAttributes(*ctx);
+
+			// Copy over any previous attributes.
+			while (!resolvedAttributes.empty()) {
+				ctx->getResolvedAttributes().push_back(resolvedAttributes.back());
+				resolvedAttributes.pop_back();
+			}
+			return ctx.release();
+        }
+        catch (...) {
+            for_each(resolvedAttributes.begin(), resolvedAttributes.end(), xmltooling::cleanup<shibsp::Attribute>());
+            resolvedAttributes.clear();
+            throw;
         }
-        return ctx.release();
     }
 
     if (!resolvedAttributes.empty()) {
@@ -438,9 +446,11 @@ ResolutionContext* AttributeResolverHandler::resolveAttributes(
         }
         catch (...) {
             for_each(resolvedAttributes.begin(), resolvedAttributes.end(), xmltooling::cleanup<shibsp::Attribute>());
+            resolvedAttributes.clear();
             throw;
         }
     }
+
     return nullptr;
 }
 

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


More information about the commits mailing list