diff options
Diffstat (limited to 'security/lasso/patches/patch-lasso-xml-tools.c')
-rw-r--r-- | security/lasso/patches/patch-lasso-xml-tools.c | 187 |
1 files changed, 135 insertions, 52 deletions
diff --git a/security/lasso/patches/patch-lasso-xml-tools.c b/security/lasso/patches/patch-lasso-xml-tools.c index 30a3acf5a2b..ee223c2fe5c 100644 --- a/security/lasso/patches/patch-lasso-xml-tools.c +++ b/security/lasso/patches/patch-lasso-xml-tools.c @@ -1,64 +1,147 @@ -$NetBSD: patch-lasso-xml-tools.c,v 1.2 2012/09/28 11:59:18 obache Exp $ +$NetBSD: patch-lasso-xml-tools.c,v 1.3 2012/10/23 18:16:15 manu Exp $ -* XXX -* for libxml>=2.9.0 +Patch from upstream to support libxml >= 2.9.0. From commit message: ---- lasso/xml/tools.c.orig 2011-01-05 13:57:32.000000000 +0000 +Libxml stopped exposing the internal of the xmlOutputBuffer structure; +it was replace by proper use of the API and of the xmlBuffer structure. + +There could be regression for older version of libxml as some functions +appeared in recent version of libxml; but the reference API document +does not give any introduction date for functions so it's hard to be +sure. + +diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c +index c4b3c8a..cda8775 100644 +--- lasso/xml/tools.c +++ lasso/xml/tools.c -@@ -27,6 +27,7 @@ - /* permit importation of timegm for glibc2, wait for people to complain it does not work on their - * system. */ - #define _BSD_SOURCE -+#define _NETBSD_SOURCE - #include "private.h" - #include <string.h> - #include <time.h> -@@ -1063,7 +1064,7 @@ lasso_node_build_deflated_query(LassoNod - buf = xmlAllocOutputBuffer(handler); - xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 0, "utf-8"); - xmlOutputBufferFlush(buf); +@@ -36,6 +36,7 @@ + #include <libxml/uri.h> + #include <libxml/parser.h> + #include <libxml/parserInternals.h> ++#include <libxml/xmlIO.h> + + #include <openssl/pem.h> + #include <openssl/sha.h> +@@ -1043,38 +1044,30 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value + return 0; + } + +-gchar* +-lasso_node_build_deflated_query(LassoNode *node) ++static gchar* ++lasso_xmlnode_build_deflated_query(xmlNode *xmlnode) + { +- /* actually deflated and b64'ed and url-escaped */ +- xmlNode *xmlnode; +- xmlOutputBufferPtr buf; +- xmlCharEncodingHandlerPtr handler = NULL; +- xmlChar *buffer; ++ xmlOutputBuffer *output_buffer; ++ xmlBuffer *buffer; + xmlChar *ret, *b64_ret; + char *rret; + unsigned long in_len; + int rc = 0; + z_stream stream; + +- xmlnode = lasso_node_get_xmlNode(node, FALSE); +- +- handler = xmlFindCharEncodingHandler("utf-8"); +- buf = xmlAllocOutputBuffer(handler); +- xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 0, "utf-8"); +- xmlOutputBufferFlush(buf); - buffer = buf->conv ? buf->conv->content : buf->buffer->content; -+ buffer = xmlBufferContent(buf->conv ? buf->conv : buf->buffer); +- +- xmlFreeNode(xmlnode); +- xmlnode = NULL; +- +- in_len = strlen((char*)buffer); ++ buffer = xmlBufferCreate(); ++ output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL); ++ xmlNodeDumpOutput(output_buffer, NULL, xmlnode, 0, 0, NULL); ++ xmlOutputBufferClose(output_buffer); ++ xmlBufferAdd(buffer, BAD_CAST "", 1); ++ lasso_release_xml_node(xmlnode); ++ in_len = strlen((char*)xmlBufferContent(buffer)); + ret = g_malloc(in_len * 2); + /* deflating should never increase the required size but we are + * more conservative than that. Twice the size should be + * enough. */ + +- stream.next_in = buffer; ++ stream.next_in = (xmlChar*)xmlBufferContent(buffer); + stream.avail_in = in_len; + stream.next_out = ret; + stream.avail_out = in_len * 2; +@@ -1097,6 +1090,7 @@ lasso_node_build_deflated_query(LassoNode *node) + rc = deflateEnd(&stream); + } + } ++ xmlBufferFree(buffer); + if (rc != Z_OK) { + lasso_release(ret); + message(G_LOG_LEVEL_CRITICAL, "Failed to deflate"); +@@ -1104,7 +1098,6 @@ lasso_node_build_deflated_query(LassoNode *node) + } + + b64_ret = xmlSecBase64Encode(ret, stream.total_out, 0); +- xmlOutputBufferClose(buf); + lasso_release(ret); + + ret = xmlURIEscapeStr(b64_ret, NULL); +@@ -1115,6 +1108,20 @@ lasso_node_build_deflated_query(LassoNode *node) + return rret; + } - xmlFreeNode(xmlnode); - xmlnode = NULL; -@@ -1196,6 +1197,11 @@ lasso_concat_url_query(const char *url, - * - * Return value: TRUE if no error occurred during evaluation, FALSE otherwise. - */ -+static void -+structuredErrorFunc (void *userData, xmlErrorPtr error) { -+ *(int *)userData = error->code; ++gchar* ++lasso_node_build_deflated_query(LassoNode *node) ++{ ++ /* actually deflated and b64'ed and url-escaped */ ++ xmlNode *xmlnode; ++ gchar *result; ++ ++ xmlnode = lasso_node_get_xmlNode(node, FALSE); ++ result = lasso_xmlnode_build_deflated_query(xmlnode); ++ xmlFreeNode(xmlnode); ++ return result; +} + ++ gboolean - lasso_eval_xpath_expression(xmlXPathContextPtr xpath_ctx, const char *expression, - xmlXPathObjectPtr *xpath_object_ptr, int *xpath_error_code) -@@ -1205,10 +1211,6 @@ lasso_eval_xpath_expression(xmlXPathCont - xmlStructuredErrorFunc oldStructuredErrorFunc; - gboolean rc = TRUE; + lasso_node_init_from_deflated_query_part(LassoNode *node, char *deflate_string) + { +@@ -2144,22 +2151,21 @@ cleanup: + char* + lasso_xmlnode_to_string(xmlNode *node, gboolean format, int level) + { +- xmlOutputBufferPtr buf; +- xmlCharEncodingHandlerPtr handler = NULL; +- xmlChar *buffer; ++ xmlOutputBufferPtr output_buffer; ++ xmlBuffer *buffer; + char *str; -- void structuredErrorFunc (G_GNUC_UNUSED void *userData, xmlErrorPtr error) { -- errorCode = error->code; -- } -- - g_return_val_if_fail(xpath_ctx != NULL && expression != NULL, FALSE); - - if (xpath_error_code) { /* reset */ -@@ -1216,6 +1218,7 @@ lasso_eval_xpath_expression(xmlXPathCont - } - oldStructuredErrorFunc = xpath_ctx->error; - xpath_ctx->error = structuredErrorFunc; -+ xpath_ctx->userData = &errorCode; - xpath_object = xmlXPathEvalExpression((xmlChar*)expression, xpath_ctx); - xpath_ctx->error = oldStructuredErrorFunc; + if (! node) + return NULL; -@@ -2156,7 +2159,7 @@ lasso_xmlnode_to_string(xmlNode *node, g - buf = xmlAllocOutputBuffer(handler); - xmlNodeDumpOutput(buf, NULL, node, level, format ? 1 : 0, "utf-8"); - xmlOutputBufferFlush(buf); +- handler = xmlFindCharEncodingHandler("utf-8"); +- buf = xmlAllocOutputBuffer(handler); +- xmlNodeDumpOutput(buf, NULL, node, level, format ? 1 : 0, "utf-8"); +- xmlOutputBufferFlush(buf); - buffer = buf->conv ? buf->conv->content : buf->buffer->content; -+ buffer = xmlBufferContent(buf->conv ? buf->conv : buf->buffer); ++ buffer = xmlBufferCreate(); ++ output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL); ++ xmlNodeDumpOutput(output_buffer, NULL, node, level, format ? 1 : 0, NULL); ++ xmlOutputBufferClose(output_buffer); ++ xmlBufferAdd(buffer, BAD_CAST "", 1); /* do not mix XML and GLib strings, so we must copy */ - str = g_strdup((char*)buffer); - xmlOutputBufferClose(buf); +- str = g_strdup((char*)buffer); +- xmlOutputBufferClose(buf); ++ str = g_strdup((char*)xmlBufferContent(buffer)); ++ xmlBufferFree(buffer); + + return str; + } +-- +1.7.4.1 + |