nokogiri 1.16.7 → 1.18.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +11 -19
- data/LICENSE-DEPENDENCIES.md +6 -6
- data/README.md +8 -5
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +189 -151
- data/ext/nokogiri/gumbo.c +69 -53
- data/ext/nokogiri/html4_document.c +10 -4
- data/ext/nokogiri/html4_element_description.c +18 -18
- data/ext/nokogiri/html4_sax_parser.c +40 -0
- data/ext/nokogiri/html4_sax_parser_context.c +48 -58
- data/ext/nokogiri/html4_sax_push_parser.c +25 -24
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +18 -33
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +2 -10
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +163 -156
- data/ext/nokogiri/xml_document_fragment.c +10 -25
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +9 -9
- data/ext/nokogiri/xml_encoding_handler.c +4 -4
- data/ext/nokogiri/xml_namespace.c +6 -6
- data/ext/nokogiri/xml_node.c +141 -104
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +54 -58
- data/ext/nokogiri/xml_relax_ng.c +35 -56
- data/ext/nokogiri/xml_sax_parser.c +156 -88
- data/ext/nokogiri/xml_sax_parser_context.c +219 -131
- data/ext/nokogiri/xml_sax_push_parser.c +68 -49
- data/ext/nokogiri/xml_schema.c +50 -85
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +2 -4
- data/ext/nokogiri/xml_xpath_context.c +103 -100
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/gumbo-parser/src/ascii.c +2 -2
- data/gumbo-parser/src/error.c +76 -48
- data/gumbo-parser/src/error.h +5 -1
- data/gumbo-parser/src/nokogiri_gumbo.h +11 -2
- data/gumbo-parser/src/parser.c +63 -25
- data/gumbo-parser/src/tokenizer.c +6 -6
- data/lib/nokogiri/class_resolver.rb +1 -1
- data/lib/nokogiri/css/node.rb +6 -2
- data/lib/nokogiri/css/parser.rb +6 -4
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +6 -66
- data/lib/nokogiri/css/selector_cache.rb +38 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -4
- data/lib/nokogiri/css/tokenizer.rex +9 -8
- data/lib/nokogiri/css/xpath_visitor.rb +43 -6
- data/lib/nokogiri/css.rb +86 -20
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/encoding_handler.rb +2 -2
- data/lib/nokogiri/html4/document.rb +44 -23
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +1 -1
- data/lib/nokogiri/html4/sax/parser.rb +23 -38
- data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
- data/lib/nokogiri/html4.rb +9 -14
- data/lib/nokogiri/html5/builder.rb +40 -0
- data/lib/nokogiri/html5/document.rb +61 -30
- data/lib/nokogiri/html5/document_fragment.rb +130 -20
- data/lib/nokogiri/html5/node.rb +4 -4
- data/lib/nokogiri/html5.rb +114 -72
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +70 -26
- data/lib/nokogiri/xml/document_fragment.rb +84 -13
- data/lib/nokogiri/xml/node.rb +82 -11
- data/lib/nokogiri/xml/node_set.rb +9 -7
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +46 -13
- data/lib/nokogiri/xml/relax_ng.rb +57 -20
- data/lib/nokogiri/xml/sax/document.rb +174 -83
- data/lib/nokogiri/xml/sax/parser.rb +115 -41
- data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/sax.rb +48 -0
- data/lib/nokogiri/xml/schema.rb +112 -45
- data/lib/nokogiri/xml/searchable.rb +38 -42
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -3
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
- data/patches/libxml2/0020-CVE-2025-6021-tree-Fix-integer-overflow-in-xmlBuildQ.patch +54 -0
- data/patches/libxml2/0021-CVE-2025-6170-Fix-potential-buffer-overflows-of-inte.patch +102 -0
- data/patches/libxml2/0022-CVE-2025-49795-schematron-Fix-null-pointer-dereferen.patch +69 -0
- data/patches/libxml2/0023-CVE-2025-49794-CVE-2025-49796-schematron-Fix-xmlSche.patch +182 -0
- data/ports/archives/libxml2-2.13.8.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.43.tar.xz +0 -0
- metadata +18 -15
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
- data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +0 -25
- data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
@@ -0,0 +1,244 @@
|
|
1
|
+
From d3e3526111097560cf7c002613e2cb1d469b59e0 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
3
|
+
Date: Sat, 21 Dec 2024 16:03:46 +0100
|
4
|
+
Subject: [PATCH] xpath: Use separate static hash table for standard functions
|
5
|
+
|
6
|
+
This avoids registering standard functions when creating an XPath
|
7
|
+
context.
|
8
|
+
|
9
|
+
Lookup of extension functions is a bit slower now, but ultimately, all
|
10
|
+
function lookups should be moved to the compilation phase.
|
11
|
+
|
12
|
+
(cherry picked from commit bf5fcf6e646bb51a0f6a3655a1d64bea97274867)
|
13
|
+
---
|
14
|
+
xpath.c | 170 ++++++++++++++++++++++++++++++++------------------------
|
15
|
+
1 file changed, 98 insertions(+), 72 deletions(-)
|
16
|
+
|
17
|
+
diff --git a/xpath.c b/xpath.c
|
18
|
+
index 485d7747..21711653 100644
|
19
|
+
--- a/xpath.c
|
20
|
+
+++ b/xpath.c
|
21
|
+
@@ -136,11 +136,48 @@
|
22
|
+
|
23
|
+
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
24
|
+
|
25
|
+
-/************************************************************************
|
26
|
+
- * *
|
27
|
+
- * Floating point stuff *
|
28
|
+
- * *
|
29
|
+
- ************************************************************************/
|
30
|
+
+static void
|
31
|
+
+xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
32
|
+
+
|
33
|
+
+static const struct {
|
34
|
+
+ const char *name;
|
35
|
+
+ xmlXPathFunction func;
|
36
|
+
+} xmlXPathStandardFunctions[] = {
|
37
|
+
+ { "boolean", xmlXPathBooleanFunction },
|
38
|
+
+ { "ceiling", xmlXPathCeilingFunction },
|
39
|
+
+ { "count", xmlXPathCountFunction },
|
40
|
+
+ { "concat", xmlXPathConcatFunction },
|
41
|
+
+ { "contains", xmlXPathContainsFunction },
|
42
|
+
+ { "id", xmlXPathIdFunction },
|
43
|
+
+ { "false", xmlXPathFalseFunction },
|
44
|
+
+ { "floor", xmlXPathFloorFunction },
|
45
|
+
+ { "last", xmlXPathLastFunction },
|
46
|
+
+ { "lang", xmlXPathLangFunction },
|
47
|
+
+ { "local-name", xmlXPathLocalNameFunction },
|
48
|
+
+ { "not", xmlXPathNotFunction },
|
49
|
+
+ { "name", xmlXPathNameFunction },
|
50
|
+
+ { "namespace-uri", xmlXPathNamespaceURIFunction },
|
51
|
+
+ { "normalize-space", xmlXPathNormalizeFunction },
|
52
|
+
+ { "number", xmlXPathNumberFunction },
|
53
|
+
+ { "position", xmlXPathPositionFunction },
|
54
|
+
+ { "round", xmlXPathRoundFunction },
|
55
|
+
+ { "string", xmlXPathStringFunction },
|
56
|
+
+ { "string-length", xmlXPathStringLengthFunction },
|
57
|
+
+ { "starts-with", xmlXPathStartsWithFunction },
|
58
|
+
+ { "substring", xmlXPathSubstringFunction },
|
59
|
+
+ { "substring-before", xmlXPathSubstringBeforeFunction },
|
60
|
+
+ { "substring-after", xmlXPathSubstringAfterFunction },
|
61
|
+
+ { "sum", xmlXPathSumFunction },
|
62
|
+
+ { "true", xmlXPathTrueFunction },
|
63
|
+
+ { "translate", xmlXPathTranslateFunction }
|
64
|
+
+};
|
65
|
+
+
|
66
|
+
+#define NUM_STANDARD_FUNCTIONS \
|
67
|
+
+ (sizeof(xmlXPathStandardFunctions) / sizeof(xmlXPathStandardFunctions[0]))
|
68
|
+
+
|
69
|
+
+#define SF_HASH_SIZE 64
|
70
|
+
+
|
71
|
+
+static unsigned char xmlXPathSFHash[SF_HASH_SIZE];
|
72
|
+
|
73
|
+
double xmlXPathNAN = 0.0;
|
74
|
+
double xmlXPathPINF = 0.0;
|
75
|
+
@@ -156,6 +193,18 @@ xmlXPathInit(void) {
|
76
|
+
xmlInitParser();
|
77
|
+
}
|
78
|
+
|
79
|
+
+ATTRIBUTE_NO_SANITIZE_INTEGER
|
80
|
+
+static unsigned
|
81
|
+
+xmlXPathSFComputeHash(const xmlChar *name) {
|
82
|
+
+ unsigned hashValue = 5381;
|
83
|
+
+ const xmlChar *ptr;
|
84
|
+
+
|
85
|
+
+ for (ptr = name; *ptr; ptr++)
|
86
|
+
+ hashValue = hashValue * 33 + *ptr;
|
87
|
+
+
|
88
|
+
+ return(hashValue);
|
89
|
+
+}
|
90
|
+
+
|
91
|
+
/**
|
92
|
+
* xmlInitXPathInternal:
|
93
|
+
*
|
94
|
+
@@ -164,6 +213,8 @@ xmlXPathInit(void) {
|
95
|
+
ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
|
96
|
+
void
|
97
|
+
xmlInitXPathInternal(void) {
|
98
|
+
+ size_t i;
|
99
|
+
+
|
100
|
+
#if defined(NAN) && defined(INFINITY)
|
101
|
+
xmlXPathNAN = NAN;
|
102
|
+
xmlXPathPINF = INFINITY;
|
103
|
+
@@ -175,8 +226,34 @@ xmlInitXPathInternal(void) {
|
104
|
+
xmlXPathPINF = 1.0 / zero;
|
105
|
+
xmlXPathNINF = -xmlXPathPINF;
|
106
|
+
#endif
|
107
|
+
+
|
108
|
+
+ /*
|
109
|
+
+ * Initialize hash table for standard functions
|
110
|
+
+ */
|
111
|
+
+
|
112
|
+
+ for (i = 0; i < SF_HASH_SIZE; i++)
|
113
|
+
+ xmlXPathSFHash[i] = UCHAR_MAX;
|
114
|
+
+
|
115
|
+
+ for (i = 0; i < NUM_STANDARD_FUNCTIONS; i++) {
|
116
|
+
+ const char *name = xmlXPathStandardFunctions[i].name;
|
117
|
+
+ int bucketIndex = xmlXPathSFComputeHash(BAD_CAST name) % SF_HASH_SIZE;
|
118
|
+
+
|
119
|
+
+ while (xmlXPathSFHash[bucketIndex] != UCHAR_MAX) {
|
120
|
+
+ bucketIndex += 1;
|
121
|
+
+ if (bucketIndex >= SF_HASH_SIZE)
|
122
|
+
+ bucketIndex = 0;
|
123
|
+
+ }
|
124
|
+
+
|
125
|
+
+ xmlXPathSFHash[bucketIndex] = i;
|
126
|
+
+ }
|
127
|
+
}
|
128
|
+
|
129
|
+
+/************************************************************************
|
130
|
+
+ * *
|
131
|
+
+ * Floating point stuff *
|
132
|
+
+ * *
|
133
|
+
+ ************************************************************************/
|
134
|
+
+
|
135
|
+
/**
|
136
|
+
* xmlXPathIsNaN:
|
137
|
+
* @val: a double value
|
138
|
+
@@ -3979,18 +4056,6 @@ xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
|
139
|
+
*/
|
140
|
+
xmlXPathFunction
|
141
|
+
xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
|
142
|
+
- if (ctxt == NULL)
|
143
|
+
- return (NULL);
|
144
|
+
-
|
145
|
+
- if (ctxt->funcLookupFunc != NULL) {
|
146
|
+
- xmlXPathFunction ret;
|
147
|
+
- xmlXPathFuncLookupFunc f;
|
148
|
+
-
|
149
|
+
- f = ctxt->funcLookupFunc;
|
150
|
+
- ret = f(ctxt->funcLookupData, name, NULL);
|
151
|
+
- if (ret != NULL)
|
152
|
+
- return(ret);
|
153
|
+
- }
|
154
|
+
return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
|
155
|
+
}
|
156
|
+
|
157
|
+
@@ -4015,6 +4080,22 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
158
|
+
if (name == NULL)
|
159
|
+
return(NULL);
|
160
|
+
|
161
|
+
+ if (ns_uri == NULL) {
|
162
|
+
+ int bucketIndex = xmlXPathSFComputeHash(name) % SF_HASH_SIZE;
|
163
|
+
+
|
164
|
+
+ while (xmlXPathSFHash[bucketIndex] != UCHAR_MAX) {
|
165
|
+
+ int funcIndex = xmlXPathSFHash[bucketIndex];
|
166
|
+
+
|
167
|
+
+ if (strcmp(xmlXPathStandardFunctions[funcIndex].name,
|
168
|
+
+ (char *) name) == 0)
|
169
|
+
+ return(xmlXPathStandardFunctions[funcIndex].func);
|
170
|
+
+
|
171
|
+
+ bucketIndex += 1;
|
172
|
+
+ if (bucketIndex >= SF_HASH_SIZE)
|
173
|
+
+ bucketIndex = 0;
|
174
|
+
+ }
|
175
|
+
+ }
|
176
|
+
+
|
177
|
+
if (ctxt->funcLookupFunc != NULL) {
|
178
|
+
xmlXPathFuncLookupFunc f;
|
179
|
+
|
180
|
+
@@ -13494,61 +13575,6 @@ xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
181
|
+
void
|
182
|
+
xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
|
183
|
+
{
|
184
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean",
|
185
|
+
- xmlXPathBooleanFunction);
|
186
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling",
|
187
|
+
- xmlXPathCeilingFunction);
|
188
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count",
|
189
|
+
- xmlXPathCountFunction);
|
190
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"concat",
|
191
|
+
- xmlXPathConcatFunction);
|
192
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains",
|
193
|
+
- xmlXPathContainsFunction);
|
194
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id",
|
195
|
+
- xmlXPathIdFunction);
|
196
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false",
|
197
|
+
- xmlXPathFalseFunction);
|
198
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor",
|
199
|
+
- xmlXPathFloorFunction);
|
200
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last",
|
201
|
+
- xmlXPathLastFunction);
|
202
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang",
|
203
|
+
- xmlXPathLangFunction);
|
204
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name",
|
205
|
+
- xmlXPathLocalNameFunction);
|
206
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not",
|
207
|
+
- xmlXPathNotFunction);
|
208
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name",
|
209
|
+
- xmlXPathNameFunction);
|
210
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri",
|
211
|
+
- xmlXPathNamespaceURIFunction);
|
212
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
|
213
|
+
- xmlXPathNormalizeFunction);
|
214
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
|
215
|
+
- xmlXPathNumberFunction);
|
216
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",
|
217
|
+
- xmlXPathPositionFunction);
|
218
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round",
|
219
|
+
- xmlXPathRoundFunction);
|
220
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string",
|
221
|
+
- xmlXPathStringFunction);
|
222
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length",
|
223
|
+
- xmlXPathStringLengthFunction);
|
224
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with",
|
225
|
+
- xmlXPathStartsWithFunction);
|
226
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring",
|
227
|
+
- xmlXPathSubstringFunction);
|
228
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before",
|
229
|
+
- xmlXPathSubstringBeforeFunction);
|
230
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after",
|
231
|
+
- xmlXPathSubstringAfterFunction);
|
232
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum",
|
233
|
+
- xmlXPathSumFunction);
|
234
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true",
|
235
|
+
- xmlXPathTrueFunction);
|
236
|
+
- xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate",
|
237
|
+
- xmlXPathTranslateFunction);
|
238
|
+
-
|
239
|
+
xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri",
|
240
|
+
(const xmlChar *)"http://www.w3.org/2002/08/xquery-functions",
|
241
|
+
xmlXPathEscapeUriFunction);
|
242
|
+
--
|
243
|
+
2.47.1
|
244
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
From 17d950ae33c23f87692aa179bacedb6743f3188a Mon Sep 17 00:00:00 2001
|
2
|
+
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
3
|
+
Date: Tue, 27 May 2025 12:53:17 +0200
|
4
|
+
Subject: [PATCH 5/9] [CVE-2025-6021] tree: Fix integer overflow in
|
5
|
+
xmlBuildQName
|
6
|
+
|
7
|
+
Fixes #926.
|
8
|
+
---
|
9
|
+
tree.c | 12 +++++++++---
|
10
|
+
1 file changed, 9 insertions(+), 3 deletions(-)
|
11
|
+
|
12
|
+
diff --git a/tree.c b/tree.c
|
13
|
+
index f097cf87..5bc95b8a 100644
|
14
|
+
--- a/tree.c
|
15
|
+
+++ b/tree.c
|
16
|
+
@@ -47,6 +47,10 @@
|
17
|
+
#include "private/error.h"
|
18
|
+
#include "private/tree.h"
|
19
|
+
|
20
|
+
+#ifndef SIZE_MAX
|
21
|
+
+ #define SIZE_MAX ((size_t)-1)
|
22
|
+
+#endif
|
23
|
+
+
|
24
|
+
int __xmlRegisterCallbacks = 0;
|
25
|
+
|
26
|
+
/************************************************************************
|
27
|
+
@@ -167,10 +171,10 @@ xmlGetParameterEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
|
28
|
+
xmlChar *
|
29
|
+
xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
|
30
|
+
xmlChar *memory, int len) {
|
31
|
+
- int lenn, lenp;
|
32
|
+
+ size_t lenn, lenp;
|
33
|
+
xmlChar *ret;
|
34
|
+
|
35
|
+
- if (ncname == NULL) return(NULL);
|
36
|
+
+ if ((ncname == NULL) || (len < 0)) return(NULL);
|
37
|
+
if (prefix == NULL) return((xmlChar *) ncname);
|
38
|
+
|
39
|
+
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
40
|
+
@@ -181,8 +185,10 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
|
41
|
+
|
42
|
+
lenn = strlen((char *) ncname);
|
43
|
+
lenp = strlen((char *) prefix);
|
44
|
+
+ if (lenn >= SIZE_MAX - lenp - 1)
|
45
|
+
+ return(NULL);
|
46
|
+
|
47
|
+
- if ((memory == NULL) || (len < lenn + lenp + 2)) {
|
48
|
+
+ if ((memory == NULL) || ((size_t) len < lenn + lenp + 2)) {
|
49
|
+
ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
|
50
|
+
if (ret == NULL)
|
51
|
+
return(NULL);
|
52
|
+
--
|
53
|
+
2.50.1
|
54
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
From 5e9ec5c107d3f5b5179c3dbc19df43df041cd55b Mon Sep 17 00:00:00 2001
|
2
|
+
From: Michael Mann <mmann78@netscape.net>
|
3
|
+
Date: Fri, 20 Jun 2025 23:05:00 -0400
|
4
|
+
Subject: [PATCH 6/9] [CVE-2025-6170] Fix potential buffer overflows of
|
5
|
+
interactive shell
|
6
|
+
|
7
|
+
Fixes #941
|
8
|
+
---
|
9
|
+
debugXML.c | 15 ++++++++++-----
|
10
|
+
result/scripts/long_command | 8 ++++++++
|
11
|
+
test/scripts/long_command.script | 6 ++++++
|
12
|
+
test/scripts/long_command.xml | 1 +
|
13
|
+
4 files changed, 25 insertions(+), 5 deletions(-)
|
14
|
+
create mode 100644 result/scripts/long_command
|
15
|
+
create mode 100644 test/scripts/long_command.script
|
16
|
+
create mode 100644 test/scripts/long_command.xml
|
17
|
+
|
18
|
+
diff --git a/debugXML.c b/debugXML.c
|
19
|
+
index ed56b0f8..452b9573 100644
|
20
|
+
--- a/debugXML.c
|
21
|
+
+++ b/debugXML.c
|
22
|
+
@@ -1033,6 +1033,10 @@ xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
|
23
|
+
xmlCtxtGenericNodeCheck(ctxt, node);
|
24
|
+
}
|
25
|
+
|
26
|
+
+#define MAX_PROMPT_SIZE 500
|
27
|
+
+#define MAX_ARG_SIZE 400
|
28
|
+
+#define MAX_COMMAND_SIZE 100
|
29
|
+
+
|
30
|
+
/**
|
31
|
+
* xmlCtxtDumpNode:
|
32
|
+
* @output: the FILE * for the output
|
33
|
+
@@ -2795,10 +2799,10 @@ void
|
34
|
+
xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
|
35
|
+
FILE * output)
|
36
|
+
{
|
37
|
+
- char prompt[500] = "/ > ";
|
38
|
+
+ char prompt[MAX_PROMPT_SIZE] = "/ > ";
|
39
|
+
char *cmdline = NULL, *cur;
|
40
|
+
- char command[100];
|
41
|
+
- char arg[400];
|
42
|
+
+ char command[MAX_COMMAND_SIZE];
|
43
|
+
+ char arg[MAX_ARG_SIZE];
|
44
|
+
int i;
|
45
|
+
xmlShellCtxtPtr ctxt;
|
46
|
+
xmlXPathObjectPtr list;
|
47
|
+
@@ -2856,7 +2860,8 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
|
48
|
+
cur++;
|
49
|
+
i = 0;
|
50
|
+
while ((*cur != ' ') && (*cur != '\t') &&
|
51
|
+
- (*cur != '\n') && (*cur != '\r')) {
|
52
|
+
+ (*cur != '\n') && (*cur != '\r') &&
|
53
|
+
+ (i < (MAX_COMMAND_SIZE - 1))) {
|
54
|
+
if (*cur == 0)
|
55
|
+
break;
|
56
|
+
command[i++] = *cur++;
|
57
|
+
@@ -2871,7 +2876,7 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
|
58
|
+
while ((*cur == ' ') || (*cur == '\t'))
|
59
|
+
cur++;
|
60
|
+
i = 0;
|
61
|
+
- while ((*cur != '\n') && (*cur != '\r') && (*cur != 0)) {
|
62
|
+
+ while ((*cur != '\n') && (*cur != '\r') && (*cur != 0) && (i < (MAX_ARG_SIZE-1))) {
|
63
|
+
if (*cur == 0)
|
64
|
+
break;
|
65
|
+
arg[i++] = *cur++;
|
66
|
+
diff --git a/result/scripts/long_command b/result/scripts/long_command
|
67
|
+
new file mode 100644
|
68
|
+
index 00000000..e6f00708
|
69
|
+
--- /dev/null
|
70
|
+
+++ b/result/scripts/long_command
|
71
|
+
@@ -0,0 +1,8 @@
|
72
|
+
+/ > b > b > Object is a Node Set :
|
73
|
+
+Set contains 1 nodes:
|
74
|
+
+1 ELEMENT a:c
|
75
|
+
+b > Unknown command This_is_a_really_long_command_string_designed_to_test_the_limits_of_the_memory_that_stores_the_comm
|
76
|
+
+b > b > Unknown command ess_currents_of_time_and_existence
|
77
|
+
+b > <?xml version="1.0"?>
|
78
|
+
+<a xmlns:a="bar"><b xmlns:a="foo">Navigating_the_labyrinthine_corridors_of_human_cognition_one_often_encounters_the_perplexing_paradox_that_the_more_we_delve_into_the_intricate_dance_of_neural_pathways_and_synaptic_firings_the_further_we_seem_to_stray_from_a_truly_holistic_understanding_of_consciousness_a_phenomenon_that_remains_as_elusive_as_a_moonbeam_caught_in_a_spiderweb_yet_undeniably_shapes_every_fleeting_thought_every_prof</b></a>
|
79
|
+
+b >
|
80
|
+
|
81
|
+
diff --git a/test/scripts/long_command.script b/test/scripts/long_command.script
|
82
|
+
new file mode 100644
|
83
|
+
index 00000000..00f6df09
|
84
|
+
--- /dev/null
|
85
|
+
+++ b/test/scripts/long_command.script
|
86
|
+
@@ -0,0 +1,6 @@
|
87
|
+
+cd a/b
|
88
|
+
+set <a:c/>
|
89
|
+
+xpath //*[namespace-uri()="foo"]
|
90
|
+
+This_is_a_really_long_command_string_designed_to_test_the_limits_of_the_memory_that_stores_the_command_please_dont_crash foo
|
91
|
+
+set Navigating_the_labyrinthine_corridors_of_human_cognition_one_often_encounters_the_perplexing_paradox_that_the_more_we_delve_into_the_intricate_dance_of_neural_pathways_and_synaptic_firings_the_further_we_seem_to_stray_from_a_truly_holistic_understanding_of_consciousness_a_phenomenon_that_remains_as_elusive_as_a_moonbeam_caught_in_a_spiderweb_yet_undeniably_shapes_every_fleeting_thought_every_profound_emotion_and_every_grand_aspiration_that_propels_our_species_ever_onward_through_the_relentless_currents_of_time_and_existence
|
92
|
+
+save -
|
93
|
+
diff --git a/test/scripts/long_command.xml b/test/scripts/long_command.xml
|
94
|
+
new file mode 100644
|
95
|
+
index 00000000..1ba44016
|
96
|
+
--- /dev/null
|
97
|
+
+++ b/test/scripts/long_command.xml
|
98
|
+
@@ -0,0 +1 @@
|
99
|
+
+<a xmlns:a="bar"><b xmlns:a="foo"/></a>
|
100
|
+
--
|
101
|
+
2.50.1
|
102
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
From 62048278a4c5fdf14d287dfb400005c0a0caa69f Mon Sep 17 00:00:00 2001
|
2
|
+
From: Michael Mann <mmann78@netscape.net>
|
3
|
+
Date: Sat, 21 Jun 2025 12:11:30 -0400
|
4
|
+
Subject: [PATCH 7/9] [CVE-2025-49795] schematron: Fix null pointer dereference
|
5
|
+
leading to DoS
|
6
|
+
|
7
|
+
Fixes #932
|
8
|
+
---
|
9
|
+
result/schematron/zvon16_0.err | 3 +++
|
10
|
+
schematron.c | 5 +++++
|
11
|
+
test/schematron/zvon16.sct | 7 +++++++
|
12
|
+
test/schematron/zvon16_0.xml | 5 +++++
|
13
|
+
4 files changed, 20 insertions(+)
|
14
|
+
create mode 100644 result/schematron/zvon16_0.err
|
15
|
+
create mode 100644 test/schematron/zvon16.sct
|
16
|
+
create mode 100644 test/schematron/zvon16_0.xml
|
17
|
+
|
18
|
+
diff --git a/result/schematron/zvon16_0.err b/result/schematron/zvon16_0.err
|
19
|
+
new file mode 100644
|
20
|
+
index 00000000..3d052409
|
21
|
+
--- /dev/null
|
22
|
+
+++ b/result/schematron/zvon16_0.err
|
23
|
+
@@ -0,0 +1,3 @@
|
24
|
+
+XPath error : Unregistered function
|
25
|
+
+./test/schematron/zvon16_0.xml:2: element book: schematron error : /library/book line 2: Book
|
26
|
+
+./test/schematron/zvon16_0.xml fails to validate
|
27
|
+
diff --git a/schematron.c b/schematron.c
|
28
|
+
index 1de25deb..da603402 100644
|
29
|
+
--- a/schematron.c
|
30
|
+
+++ b/schematron.c
|
31
|
+
@@ -1506,6 +1506,11 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
|
32
|
+
select = xmlGetNoNsProp(child, BAD_CAST "select");
|
33
|
+
comp = xmlXPathCtxtCompile(ctxt->xctxt, select);
|
34
|
+
eval = xmlXPathCompiledEval(comp, ctxt->xctxt);
|
35
|
+
+ if (eval == NULL) {
|
36
|
+
+ xmlXPathFreeCompExpr(comp);
|
37
|
+
+ xmlFree(select);
|
38
|
+
+ return ret;
|
39
|
+
+ }
|
40
|
+
|
41
|
+
switch (eval->type) {
|
42
|
+
case XPATH_NODESET: {
|
43
|
+
diff --git a/test/schematron/zvon16.sct b/test/schematron/zvon16.sct
|
44
|
+
new file mode 100644
|
45
|
+
index 00000000..f03848aa
|
46
|
+
--- /dev/null
|
47
|
+
+++ b/test/schematron/zvon16.sct
|
48
|
+
@@ -0,0 +1,7 @@
|
49
|
+
+<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
|
50
|
+
+ <sch:pattern id="TestPattern">
|
51
|
+
+ <sch:rule context="book">
|
52
|
+
+ <sch:report test="not(@available)">Book <sch:value-of select="falae()"/> test</sch:report>
|
53
|
+
+ </sch:rule>
|
54
|
+
+ </sch:pattern>
|
55
|
+
+</sch:schema>
|
56
|
+
diff --git a/test/schematron/zvon16_0.xml b/test/schematron/zvon16_0.xml
|
57
|
+
new file mode 100644
|
58
|
+
index 00000000..551e2d65
|
59
|
+
--- /dev/null
|
60
|
+
+++ b/test/schematron/zvon16_0.xml
|
61
|
+
@@ -0,0 +1,5 @@
|
62
|
+
+<library>
|
63
|
+
+ <book title="Test Book" id="bk101">
|
64
|
+
+ <author>Test Author</author>
|
65
|
+
+ </book>
|
66
|
+
+</library>
|
67
|
+
--
|
68
|
+
2.50.1
|
69
|
+
|
@@ -0,0 +1,182 @@
|
|
1
|
+
From 81cef8c5b5aec2acdf5707e57a6db0c8d1d0abca Mon Sep 17 00:00:00 2001
|
2
|
+
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
3
|
+
Date: Fri, 4 Jul 2025 14:28:26 +0200
|
4
|
+
Subject: [PATCH 8/9] [CVE-2025-49794] [CVE-2025-49796] schematron: Fix
|
5
|
+
xmlSchematronReportOutput
|
6
|
+
|
7
|
+
Fix use-after-free (CVE-2025-49794) and type confusion (CVE-2025-49796)
|
8
|
+
in xmlSchematronReportOutput.
|
9
|
+
|
10
|
+
Fixes #931.
|
11
|
+
Fixes #933.
|
12
|
+
---
|
13
|
+
result/schematron/cve-2025-49794_0.err | 2 ++
|
14
|
+
result/schematron/cve-2025-49796_0.err | 2 ++
|
15
|
+
schematron.c | 49 ++++++++++++++------------
|
16
|
+
test/schematron/cve-2025-49794.sct | 10 ++++++
|
17
|
+
test/schematron/cve-2025-49794_0.xml | 6 ++++
|
18
|
+
test/schematron/cve-2025-49796.sct | 9 +++++
|
19
|
+
test/schematron/cve-2025-49796_0.xml | 3 ++
|
20
|
+
7 files changed, 58 insertions(+), 23 deletions(-)
|
21
|
+
create mode 100644 result/schematron/cve-2025-49794_0.err
|
22
|
+
create mode 100644 result/schematron/cve-2025-49796_0.err
|
23
|
+
create mode 100644 test/schematron/cve-2025-49794.sct
|
24
|
+
create mode 100644 test/schematron/cve-2025-49794_0.xml
|
25
|
+
create mode 100644 test/schematron/cve-2025-49796.sct
|
26
|
+
create mode 100644 test/schematron/cve-2025-49796_0.xml
|
27
|
+
|
28
|
+
diff --git a/result/schematron/cve-2025-49794_0.err b/result/schematron/cve-2025-49794_0.err
|
29
|
+
new file mode 100644
|
30
|
+
index 00000000..57752310
|
31
|
+
--- /dev/null
|
32
|
+
+++ b/result/schematron/cve-2025-49794_0.err
|
33
|
+
@@ -0,0 +1,2 @@
|
34
|
+
+./test/schematron/cve-2025-49794_0.xml:2: element boo0: schematron error : /librar0/boo0 line 2:
|
35
|
+
+./test/schematron/cve-2025-49794_0.xml fails to validate
|
36
|
+
diff --git a/result/schematron/cve-2025-49796_0.err b/result/schematron/cve-2025-49796_0.err
|
37
|
+
new file mode 100644
|
38
|
+
index 00000000..bf875ee0
|
39
|
+
--- /dev/null
|
40
|
+
+++ b/result/schematron/cve-2025-49796_0.err
|
41
|
+
@@ -0,0 +1,2 @@
|
42
|
+
+./test/schematron/cve-2025-49796_0.xml:2: element boo0: schematron error : /librar0/boo0 line 2:
|
43
|
+
+./test/schematron/cve-2025-49796_0.xml fails to validate
|
44
|
+
diff --git a/schematron.c b/schematron.c
|
45
|
+
index da603402..6e2ceeb7 100644
|
46
|
+
--- a/schematron.c
|
47
|
+
+++ b/schematron.c
|
48
|
+
@@ -1414,27 +1414,15 @@ xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt)
|
49
|
+
* *
|
50
|
+
************************************************************************/
|
51
|
+
|
52
|
+
-static xmlNodePtr
|
53
|
+
+static xmlXPathObjectPtr
|
54
|
+
xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt,
|
55
|
+
xmlNodePtr cur, const xmlChar *xpath) {
|
56
|
+
- xmlNodePtr node = NULL;
|
57
|
+
- xmlXPathObjectPtr ret;
|
58
|
+
-
|
59
|
+
if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL))
|
60
|
+
return(NULL);
|
61
|
+
|
62
|
+
ctxt->xctxt->doc = cur->doc;
|
63
|
+
ctxt->xctxt->node = cur;
|
64
|
+
- ret = xmlXPathEval(xpath, ctxt->xctxt);
|
65
|
+
- if (ret == NULL)
|
66
|
+
- return(NULL);
|
67
|
+
-
|
68
|
+
- if ((ret->type == XPATH_NODESET) &&
|
69
|
+
- (ret->nodesetval != NULL) && (ret->nodesetval->nodeNr > 0))
|
70
|
+
- node = ret->nodesetval->nodeTab[0];
|
71
|
+
-
|
72
|
+
- xmlXPathFreeObject(ret);
|
73
|
+
- return(node);
|
74
|
+
+ return(xmlXPathEval(xpath, ctxt->xctxt));
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
@@ -1480,25 +1468,40 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
|
79
|
+
(child->type == XML_CDATA_SECTION_NODE))
|
80
|
+
ret = xmlStrcat(ret, child->content);
|
81
|
+
else if (IS_SCHEMATRON(child, "name")) {
|
82
|
+
+ xmlXPathObject *obj = NULL;
|
83
|
+
xmlChar *path;
|
84
|
+
|
85
|
+
path = xmlGetNoNsProp(child, BAD_CAST "path");
|
86
|
+
|
87
|
+
node = cur;
|
88
|
+
if (path != NULL) {
|
89
|
+
- node = xmlSchematronGetNode(ctxt, cur, path);
|
90
|
+
- if (node == NULL)
|
91
|
+
- node = cur;
|
92
|
+
+ obj = xmlSchematronGetNode(ctxt, cur, path);
|
93
|
+
+ if ((obj != NULL) &&
|
94
|
+
+ (obj->type == XPATH_NODESET) &&
|
95
|
+
+ (obj->nodesetval != NULL) &&
|
96
|
+
+ (obj->nodesetval->nodeNr > 0))
|
97
|
+
+ node = obj->nodesetval->nodeTab[0];
|
98
|
+
xmlFree(path);
|
99
|
+
}
|
100
|
+
|
101
|
+
- if ((node->ns == NULL) || (node->ns->prefix == NULL))
|
102
|
+
- ret = xmlStrcat(ret, node->name);
|
103
|
+
- else {
|
104
|
+
- ret = xmlStrcat(ret, node->ns->prefix);
|
105
|
+
- ret = xmlStrcat(ret, BAD_CAST ":");
|
106
|
+
- ret = xmlStrcat(ret, node->name);
|
107
|
+
+ switch (node->type) {
|
108
|
+
+ case XML_ELEMENT_NODE:
|
109
|
+
+ case XML_ATTRIBUTE_NODE:
|
110
|
+
+ if ((node->ns == NULL) || (node->ns->prefix == NULL))
|
111
|
+
+ ret = xmlStrcat(ret, node->name);
|
112
|
+
+ else {
|
113
|
+
+ ret = xmlStrcat(ret, node->ns->prefix);
|
114
|
+
+ ret = xmlStrcat(ret, BAD_CAST ":");
|
115
|
+
+ ret = xmlStrcat(ret, node->name);
|
116
|
+
+ }
|
117
|
+
+ break;
|
118
|
+
+
|
119
|
+
+ /* TODO: handle other node types */
|
120
|
+
+ default:
|
121
|
+
+ break;
|
122
|
+
}
|
123
|
+
+
|
124
|
+
+ xmlXPathFreeObject(obj);
|
125
|
+
} else if (IS_SCHEMATRON(child, "value-of")) {
|
126
|
+
xmlChar *select;
|
127
|
+
xmlXPathObjectPtr eval;
|
128
|
+
diff --git a/test/schematron/cve-2025-49794.sct b/test/schematron/cve-2025-49794.sct
|
129
|
+
new file mode 100644
|
130
|
+
index 00000000..7fc9ee3d
|
131
|
+
--- /dev/null
|
132
|
+
+++ b/test/schematron/cve-2025-49794.sct
|
133
|
+
@@ -0,0 +1,10 @@
|
134
|
+
+<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
|
135
|
+
+ <sch:pattern id="">
|
136
|
+
+ <sch:rule context="boo0">
|
137
|
+
+ <sch:report test="not(0)">
|
138
|
+
+ <sch:name path="	e|namespace::*|e"/>
|
139
|
+
+ </sch:report>
|
140
|
+
+ <sch:report test="0"></sch:report>
|
141
|
+
+ </sch:rule>
|
142
|
+
+ </sch:pattern>
|
143
|
+
+</sch:schema>
|
144
|
+
diff --git a/test/schematron/cve-2025-49794_0.xml b/test/schematron/cve-2025-49794_0.xml
|
145
|
+
new file mode 100644
|
146
|
+
index 00000000..debc64ba
|
147
|
+
--- /dev/null
|
148
|
+
+++ b/test/schematron/cve-2025-49794_0.xml
|
149
|
+
@@ -0,0 +1,6 @@
|
150
|
+
+<librar0>
|
151
|
+
+ <boo0 t="">
|
152
|
+
+ <author></author>
|
153
|
+
+ </boo0>
|
154
|
+
+ <ins></ins>
|
155
|
+
+</librar0>
|
156
|
+
diff --git a/test/schematron/cve-2025-49796.sct b/test/schematron/cve-2025-49796.sct
|
157
|
+
new file mode 100644
|
158
|
+
index 00000000..e9702d75
|
159
|
+
--- /dev/null
|
160
|
+
+++ b/test/schematron/cve-2025-49796.sct
|
161
|
+
@@ -0,0 +1,9 @@
|
162
|
+
+<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
|
163
|
+
+ <sch:pattern id="">
|
164
|
+
+ <sch:rule context="boo0">
|
165
|
+
+ <sch:report test="not(0)">
|
166
|
+
+ <sch:name path="/"/>
|
167
|
+
+ </sch:report>
|
168
|
+
+ </sch:rule>
|
169
|
+
+ </sch:pattern>
|
170
|
+
+</sch:schema>
|
171
|
+
diff --git a/test/schematron/cve-2025-49796_0.xml b/test/schematron/cve-2025-49796_0.xml
|
172
|
+
new file mode 100644
|
173
|
+
index 00000000..be33c4ec
|
174
|
+
--- /dev/null
|
175
|
+
+++ b/test/schematron/cve-2025-49796_0.xml
|
176
|
+
@@ -0,0 +1,3 @@
|
177
|
+
+<librar0>
|
178
|
+
+ <boo0/>
|
179
|
+
+</librar0>
|
180
|
+
--
|
181
|
+
2.50.1
|
182
|
+
|
Binary file
|
Binary file
|