From 1fbf95be686300f265aa13ac45636fbabb6a1d1e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 31 Jul 2014 13:42:10 -0400 Subject: [PATCH 2/3] Assert on missing id In this function id is required, so just assert if it is missing. This also silences a warning about "reference" being used unintialized if "id" is null. License: MIT Signed-off-by: Simo Sorce --- lasso/xml/tools.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index fd3defbe1f0559c6cbb1ef17bbdd020170d485f5..09f7da8541b15e0a60e370111968f38b4f93f366 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -2525,6 +2525,8 @@ lasso_xmlnode_add_saml2_signature_template(xmlNode *node, LassoSignatureContext xmlNode *existing_signature = NULL, *signature = NULL, *reference, *key_info; char *uri; + g_assert(id); + if (! lasso_validate_signature_context(context) || ! node) return; @@ -2555,12 +2557,10 @@ lasso_xmlnode_add_saml2_signature_template(xmlNode *node, LassoSignatureContext * other cases, set snippet->offset to 0 and use xmlSecTmpSignatureAddReference from another * node get_xmlNode virtual method to add the needed reference. */ - if (id) { - uri = g_strdup_printf("#%s", id); - reference = xmlSecTmplSignatureAddReference(signature, - xmlSecTransformSha1Id, NULL, (xmlChar*)uri, NULL); - lasso_release(uri); - } + uri = g_strdup_printf("#%s", id); + reference = xmlSecTmplSignatureAddReference(signature, + xmlSecTransformSha1Id, NULL, (xmlChar*)uri, NULL); + lasso_release(uri); /* add enveloped transform */ xmlSecTmplReferenceAddTransform(reference, xmlSecTransformEnvelopedId); -- 1.9.3