components/libxml2/patches/17.CVE-2010-4008.patch
changeset 868 bb69a554cd60
equal deleted inserted replaced
867:181d993d52cf 868:bb69a554cd60
       
     1 There are 2 patches in a row to the same section of code here, they are copied/pasted
       
     2 directly from:
       
     3 http://git.gnome.org/browse/libxml2/patch/?id=91d19754d46acd4a639a8b9e31f50f31c78f8c9c
       
     4 http://git.gnome.org/browse/libxml2/patch/?id=ea90b894146030c214a7df6d8375310174f134b9
       
     5 --------------------------------------------------------------------------------------
       
     6 From 91d19754d46acd4a639a8b9e31f50f31c78f8c9c Mon Sep 17 00:00:00 2001
       
     7 From: Daniel Veillard <[email protected]>
       
     8 Date: Fri, 15 Oct 2010 12:30:52 +0000
       
     9 Subject: Fix the semantic of XPath axis for namespace/attribute context nodes
       
    10 
       
    11 The processing of namespace and attributes nodes was not compliant
       
    12 to the XPath-1.0 specification
       
    13 ---
       
    14 diff --git a/xpath.c b/xpath.c
       
    15 index b24ca69..8b77af3 100644
       
    16 --- a/xpath.c
       
    17 +++ b/xpath.c
       
    18 @@ -8106,8 +8106,16 @@ xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
       
    19  xmlNodePtr
       
    20  xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
       
    21      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
    22 -    if (cur != NULL && cur->children != NULL)
       
    23 -        return cur->children ;
       
    24 +    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
    25 +	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
    26 +	return(NULL);
       
    27 +    if (cur != NULL) {
       
    28 +        if ((cur->type == XML_ATTRIBUTE_NODE) ||
       
    29 +            (cur->type == XML_NAMESPACE_DECL))
       
    30 +            return(NULL);
       
    31 +        if (cur->children != NULL)
       
    32 +            return cur->children ;
       
    33 +    }
       
    34      if (cur == NULL) cur = ctxt->context->node;
       
    35      if (cur == NULL) return(NULL) ; /* ERROR */
       
    36      if (cur->next != NULL) return(cur->next) ;
       
    37 @@ -8162,6 +8170,9 @@ xmlNodePtr
       
    38  xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
       
    39  {
       
    40      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
    41 +    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
    42 +	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
    43 +	return(NULL);
       
    44      if (cur == NULL)
       
    45          cur = ctxt->context->node;
       
    46      if (cur == NULL)
       
    47 @@ -8203,12 +8214,13 @@ xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
       
    48                                xmlNodePtr cur)
       
    49  {
       
    50      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
    51 +    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
    52 +	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
    53 +	return(NULL);
       
    54      if (cur == NULL) {
       
    55          cur = ctxt->context->node;
       
    56          if (cur == NULL)
       
    57              return (NULL);
       
    58 -	if (cur->type == XML_NAMESPACE_DECL)
       
    59 -	    cur = (xmlNodePtr)((xmlNsPtr)cur)->next;
       
    60          ctxt->ancestor = cur->parent;
       
    61      }
       
    62      if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE))
       
    63 --
       
    64 cgit v0.9.0.2
       
    65 
       
    66 From ea90b894146030c214a7df6d8375310174f134b9 Mon Sep 17 00:00:00 2001
       
    67 From: Daniel Veillard <[email protected]>
       
    68 Date: Fri, 22 Oct 2010 13:50:50 +0000
       
    69 Subject: Fix a change of semantic on XPath preceding and following axis
       
    70 
       
    71 This was introduced in the prevous fix, while preceding-sibling and
       
    72 following sibling axis are empty for attributes and namespaces,
       
    73 preceding and following axis should still work based on the parent
       
    74 element. However the parent element is not available for a namespace
       
    75 node, so we keep the axis empty in that case.
       
    76 ---
       
    77 diff --git a/xpath.c b/xpath.c
       
    78 index 9d47618..3352a5e 100644
       
    79 --- a/xpath.c
       
    80 +++ b/xpath.c
       
    81 @@ -8106,17 +8106,17 @@ xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
       
    82  xmlNodePtr
       
    83  xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
       
    84      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
    85 -    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
    86 -	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
    87 -	return(NULL);
       
    88 -    if (cur != NULL) {
       
    89 -        if ((cur->type == XML_ATTRIBUTE_NODE) ||
       
    90 -            (cur->type == XML_NAMESPACE_DECL))
       
    91 +    if ((cur != NULL) && (cur->type  != XML_ATTRIBUTE_NODE) &&
       
    92 +        (cur->type != XML_NAMESPACE_DECL) && (cur->children != NULL))
       
    93 +        return(cur->children);
       
    94 +
       
    95 +    if (cur == NULL) {
       
    96 +        cur = ctxt->context->node;
       
    97 +        if (cur->type == XML_NAMESPACE_DECL)
       
    98              return(NULL);
       
    99 -        if (cur->children != NULL)
       
   100 -            return cur->children ;
       
   101 +        if (cur->type == XML_ATTRIBUTE_NODE)
       
   102 +            cur = cur->parent;
       
   103      }
       
   104 -    if (cur == NULL) cur = ctxt->context->node;
       
   105      if (cur == NULL) return(NULL) ; /* ERROR */
       
   106      if (cur->next != NULL) return(cur->next) ;
       
   107      do {
       
   108 @@ -8170,11 +8170,13 @@ xmlNodePtr
       
   109  xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
       
   110  {
       
   111      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
   112 -    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
   113 -	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
   114 -	return(NULL);
       
   115 -    if (cur == NULL)
       
   116 +    if (cur == NULL) {
       
   117          cur = ctxt->context->node;
       
   118 +        if (cur->type == XML_NAMESPACE_DECL)
       
   119 +            return(NULL);
       
   120 +        if (cur->type == XML_ATTRIBUTE_NODE)
       
   121 +            return(cur->parent);
       
   122 +    }
       
   123      if (cur == NULL)
       
   124  	return (NULL);
       
   125      if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE))
       
   126 @@ -8214,13 +8216,12 @@ xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
       
   127                                xmlNodePtr cur)
       
   128  {
       
   129      if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
       
   130 -    if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
       
   131 -	(ctxt->context->node->type == XML_NAMESPACE_DECL))
       
   132 -	return(NULL);
       
   133      if (cur == NULL) {
       
   134          cur = ctxt->context->node;
       
   135          if (cur == NULL)
       
   136              return (NULL);
       
   137 +        if (cur->type == XML_NAMESPACE_DECL)
       
   138 +            return (NULL);
       
   139          ctxt->ancestor = cur->parent;
       
   140      }
       
   141      if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE))
       
   142 --
       
   143 cgit v0.9.0.2