|
1 Patch origin: upstream |
|
2 Patch status: will be part of next version |
|
3 |
|
4 https://git.gnome.org/browse/libxml2/commit/?id=9cd1c3cfbd32655d60572c0a413e017260c854df |
|
5 https://git.gnome.org/browse/libxml2/commit/?id=dd8367da17c2948981a51e52c8a6beb445edf825 |
|
6 https://git.gnome.org/browse/libxml2/commit/?id=c35af8b18dddd0bdfb137ad6a056837a3d5ea651 |
|
7 |
|
8 From 9cd1c3cfbd32655d60572c0a413e017260c854df Mon Sep 17 00:00:00 2001 |
|
9 From: Daniel Veillard <[email protected]> |
|
10 Date: Tue, 22 Apr 2014 15:30:56 +0800 |
|
11 Subject: Do not fetch external parameter entities |
|
12 |
|
13 Unless explicitely asked for when validating or replacing entities |
|
14 with their value. Problem pointed out by Daniel Berrange <[email protected]> |
|
15 |
|
16 diff --git a/parser.c b/parser.c |
|
17 index 9347ac9..c0dea05 100644 |
|
18 --- a/parser.c |
|
19 +++ b/parser.c |
|
20 @@ -2598,6 +2598,20 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { |
|
21 xmlCharEncoding enc; |
|
22 |
|
23 /* |
|
24 + * Note: external parsed entities will not be loaded, it is |
|
25 + * not required for a non-validating parser, unless the |
|
26 + * option of validating, or substituting entities were |
|
27 + * given. Doing so is far more secure as the parser will |
|
28 + * only process data coming from the document entity by |
|
29 + * default. |
|
30 + */ |
|
31 + if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && |
|
32 + ((ctxt->options & XML_PARSE_NOENT) == 0) && |
|
33 + ((ctxt->options & XML_PARSE_DTDVALID) == 0) && |
|
34 + (ctxt->validate == 0)) |
|
35 + return; |
|
36 + |
|
37 + /* |
|
38 * handle the extra spaces added before and after |
|
39 * c.f. http://www.w3.org/TR/REC-xml#as-PE |
|
40 * this is done independently. |
|
41 -- |
|
42 cgit v0.10.1 |
|
43 |
|
44 From dd8367da17c2948981a51e52c8a6beb445edf825 Mon Sep 17 00:00:00 2001 |
|
45 From: Daniel Veillard <[email protected]> |
|
46 Date: Wed, 11 Jun 2014 16:54:32 +0800 |
|
47 Subject: Fix regressions introduced by CVE-2014-0191 patch |
|
48 |
|
49 A number of issues have been raised after the fix, and this patch |
|
50 tries to correct all of them, though most were related to |
|
51 postvalidation. |
|
52 https://bugzilla.gnome.org/show_bug.cgi?id=730290 |
|
53 and other reports on list, off-list and on Red Hat bugzilla |
|
54 |
|
55 diff --git a/parser.c b/parser.c |
|
56 index c0dea05..ba70f9e 100644 |
|
57 --- a/parser.c |
|
58 +++ b/parser.c |
|
59 @@ -2598,8 +2598,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { |
|
60 xmlCharEncoding enc; |
|
61 |
|
62 /* |
|
63 - * Note: external parsed entities will not be loaded, it is |
|
64 - * not required for a non-validating parser, unless the |
|
65 + * Note: external parameter entities will not be loaded, it |
|
66 + * is not required for a non-validating parser, unless the |
|
67 * option of validating, or substituting entities were |
|
68 * given. Doing so is far more secure as the parser will |
|
69 * only process data coming from the document entity by |
|
70 @@ -2608,6 +2608,9 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { |
|
71 if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && |
|
72 ((ctxt->options & XML_PARSE_NOENT) == 0) && |
|
73 ((ctxt->options & XML_PARSE_DTDVALID) == 0) && |
|
74 + ((ctxt->options & XML_PARSE_DTDLOAD) == 0) && |
|
75 + ((ctxt->options & XML_PARSE_DTDATTR) == 0) && |
|
76 + (ctxt->replaceEntities == 0) && |
|
77 (ctxt->validate == 0)) |
|
78 return; |
|
79 |
|
80 @@ -12616,6 +12619,9 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input, |
|
81 return(NULL); |
|
82 } |
|
83 |
|
84 + /* We are loading a DTD */ |
|
85 + ctxt->options |= XML_PARSE_DTDLOAD; |
|
86 + |
|
87 /* |
|
88 * Set-up the SAX context |
|
89 */ |
|
90 @@ -12743,6 +12749,9 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID, |
|
91 return(NULL); |
|
92 } |
|
93 |
|
94 + /* We are loading a DTD */ |
|
95 + ctxt->options |= XML_PARSE_DTDLOAD; |
|
96 + |
|
97 /* |
|
98 * Set-up the SAX context |
|
99 */ |
|
100 -- |
|
101 cgit v0.10.1 |
|
102 |
|
103 From c35af8b18dddd0bdfb137ad6a056837a3d5ea651 Mon Sep 17 00:00:00 2001 |
|
104 From: Daniel Veillard <[email protected]> |
|
105 Date: Wed, 11 Jun 2014 16:59:16 +0800 |
|
106 Subject: Fixes for xmlInitParserCtxt |
|
107 |
|
108 let's make sure that parser options are updated too when a corrsponding |
|
109 global variable or other field of the context is set. |
|
110 |
|
111 diff --git a/parserInternals.c b/parserInternals.c |
|
112 index 98a5836..df204fd 100644 |
|
113 --- a/parserInternals.c |
|
114 +++ b/parserInternals.c |
|
115 @@ -1691,12 +1691,20 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt) |
|
116 ctxt->nsWellFormed = 1; |
|
117 ctxt->valid = 1; |
|
118 ctxt->loadsubset = xmlLoadExtDtdDefaultValue; |
|
119 + if (ctxt->loadsubset) { |
|
120 + ctxt->options |= XML_PARSE_DTDLOAD; |
|
121 + } |
|
122 ctxt->validate = xmlDoValidityCheckingDefaultValue; |
|
123 ctxt->pedantic = xmlPedanticParserDefaultValue; |
|
124 + if (ctxt->pedantic) { |
|
125 + ctxt->options |= XML_PARSE_PEDANTIC; |
|
126 + } |
|
127 ctxt->linenumbers = xmlLineNumbersDefaultValue; |
|
128 ctxt->keepBlanks = xmlKeepBlanksDefaultValue; |
|
129 - if (ctxt->keepBlanks == 0) |
|
130 + if (ctxt->keepBlanks == 0) { |
|
131 ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace; |
|
132 + ctxt->options |= XML_PARSE_NOBLANKS; |
|
133 + } |
|
134 |
|
135 ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0; |
|
136 ctxt->vctxt.userData = ctxt; |
|
137 @@ -1708,8 +1716,12 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt) |
|
138 else |
|
139 ctxt->vctxt.warning = xmlParserValidityWarning; |
|
140 ctxt->vctxt.nodeMax = 0; |
|
141 + ctxt->options |= XML_PARSE_DTDVALID; |
|
142 } |
|
143 ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue; |
|
144 + if (ctxt->replaceEntities) { |
|
145 + ctxt->options |= XML_PARSE_NOENT; |
|
146 + } |
|
147 ctxt->record_info = 0; |
|
148 ctxt->nbChars = 0; |
|
149 ctxt->checkIndex = 0; |
|
150 -- |
|
151 cgit v0.10.1 |
|
152 |