leptris 1.9.425.0-aarch64-linux → 1.9.426.1-aarch64-linux
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/Rakefile +10 -1
- data/SUPPORTED_MINORS +1 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native_3_1.so +0 -0
- data/lib/leptris/xml/native_3_2.so +0 -0
- data/lib/leptris/xml/native_3_4.so +0 -0
- data/lib/leptris/xml/native_4_0.so +0 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +19 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +8 -0
- data/vendor-src/libleptris/src/leptris/xpath/compiler.c +6 -2
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +13 -1
- data/vendor-src/libleptris/src/leptris/xpath/parser.c +8 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_ast_cache.c +36 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_compiled.c +41 -41
- data/vendor-src/libleptris/src/leptris/xpath/xpath_internal.h +7 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_exec.c +58 -6
- data/vendor-src/libleptris/src/leptris/xslt/xslt_internal.h +10 -0
- data/vendor-src/libleptris/test/differential/rs-runner/Cargo.toml +1 -1
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0000.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0001.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0002.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0003.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0004.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0005.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0006.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0007.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0008.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0009.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0010.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0011.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0012.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0013.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0014.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0015.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0016.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0017.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0018.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0019.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0020.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0021.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0022.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0023.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0024.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0025.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0026.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0027.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0028.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0029.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0030.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0031.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0032.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0033.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0034.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0035.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0036.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0037.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0038.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/gen/gen_0039.xsl +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_astcache_uaf_fold.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_astcache_uaf_nightly.bin +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_dyncall_nontext_callee_segv.xml +0 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xslt_seeds.py +152 -0
- data/vendor-src/libleptris/test/xpath/test_xpath.cpp +30 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +51 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10c9a23682562c64e2f4d93a15290f6a810ffd0a4566ae5e72bb5cc4c7729676
|
|
4
|
+
data.tar.gz: cc28de773cd7fe6cbb0119865c7a52832284c70df7f60ff209baffd2ddbf7fb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd892eb3f7a26eb722d3769975e4f25e7d1635aa6a9d9e745d17d97ec1410983ae69dc70aa3ffaef22892d6721460b5e02ced8a6b6a9d1339b37333662354649
|
|
7
|
+
data.tar.gz: 9d8fd2e215416d131bd2f8cada7af1ba4b6b024ea168edd3400975e65e5e8d4d1d2daeb5d34b65e0fbeb5d2b3c802c83732a512048d2b1a7795e94cc3dcac30c
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,16 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.426"
|
|
12
|
+
|
|
13
|
+
# THE SSOT for the per-minor native bundle list (ruby#645): one line,
|
|
14
|
+
# space-separated, consumed by the Rakefile, the per-minor builder's
|
|
15
|
+
# callers, and the release workflow's container loops + publication
|
|
16
|
+
# gates (`cat SUPPORTED_MINORS`). A minor joins here and every
|
|
17
|
+
# platform's matrix covers it; it leaves here and every gate stops
|
|
18
|
+
# requiring it. NO OTHER COPY of this list may exist in this repo.
|
|
19
|
+
SUPPORTED_RUBY_MINORS = File.read("SUPPORTED_MINORS").split.freeze
|
|
20
|
+
SUPPORTED_RUBY_MINORS_US = SUPPORTED_RUBY_MINORS.map { |v| v.tr(".", "_") }.freeze
|
|
12
21
|
# Vendored alongside libleptris for fn:normalize-unicode (TODO
|
|
13
22
|
# .restructure/20): built per platform with a RELOCATABLE @rpath
|
|
14
23
|
# install name, loaded by ffi.rb before libleptris so the
|
data/SUPPORTED_MINORS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1 3.2 3.3 3.4 4.0
|
data/lib/leptris/version.rb
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.426] - 2026-11-17
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
The fuzz-lane's finding-6 wave: the nightly's grammar-aware generator drove into the FN-carrier machinery, and five fixes landed in four days.
|
|
8
|
+
|
|
9
|
+
- **xpath: the dynamic call's blind text-node cast crashed** (fuzz_xslt, nightly 43980029629, `node()()`). The dyn-call fetch read the callee nodeset's first node as an `XPathTextNode` without checking its type — every sibling fetch gates on the node type, this one didn't; an element-led callee read element bytes as a content pointer and `strncmp` dereferenced wild memory. The fetch now type-gates like its siblings; a non-text callee refuses.
|
|
10
|
+
- **xpath: the fast eval path ran its VM on an unpinned bytecode borrow** (nightly 43985564879). libxslt bug-147 (PR #600) taught the ns-context eval path the pinned borrow — a re-entrant store during the run can evict the slot and free the bytecode, whose constants hold cache-AST pointers — but the FAST path (the no-ns route behind the XSLT exec's hot path) never received it. The borrow now lives in one `compiled_eval_bc_pinned` helper shared by both eval paths.
|
|
11
|
+
- **xslt: transient compiles promote to exec-lifetime** (nightly 44046875569). The FN carrier's body is borrowed from its enclosing compiled expression ("transform-lifetime" per the synthesis contract), and three sites compiled transiently and freed after one eval — `op_evaluate`'s dynamic expression, the apply-imports caller-param loop (freed right after pushing the carrier as a binding), and the `@*` pattern probe. All three compile onto an exec-lifetime deduped chain (the AVT cache's pattern) freed at `xslt_exec_free` — the v1 carrier contract becomes true instead of assumed.
|
|
12
|
+
- **xpath: the constant-fold admitted NUMBER literals and strlen'd their NULL value** (the fold crasher, standalone-reproducible). The fold validation accepted STRING *and* NUMBER children while every fold body strlens `child->value` — a NUMBER node's value is NULL; `concat('a', 42)` folded into `strlen(NULL)`. The fold is a string-literal optimization; numbers decline it.
|
|
13
|
+
- **xpath: the FN carrier adopts its closure body.** The lifetime half: synthesis embeds the body's AST address as hex inside the carrier, the body was borrowed, and a carrier surviving in a binding outlived its owner. Synthesis now adopts the body into a process-lifetime registry (`ast_node_free` skips adopted subtrees) — the pointer in the string finally carries ownership, not a hope. Idempotent, bounded by distinct closure bodies, the carrier format unchanged.
|
|
14
|
+
|
|
15
|
+
### Tooling
|
|
16
|
+
|
|
17
|
+
- **the grammar-aware XSLT seed generator** (#2051): the nightly composes 200 deep structured stylesheets per run (axis paths, predicates, unions, arithmetic trees, nested constructors) so libFuzzer anchors at expression depths pure mutation cannot build. This wave's findings came out of exactly those depths.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
3
22
|
## [1.9.425] - 2026-11-16
|
|
4
23
|
|
|
5
24
|
### Fixed
|
|
@@ -656,6 +656,14 @@ typedef struct xpath_ast_node {
|
|
|
656
656
|
* guards the lazy init (0 until first use). */
|
|
657
657
|
uint16_t local_hash;
|
|
658
658
|
uint8_t local_hash_set;
|
|
659
|
+
|
|
660
|
+
/* SOTA C1 finding 6: OWNED by the FN-carrier adoption registry
|
|
661
|
+
* (xpath_ast_cache_adopt) — a closure body whose carrier can
|
|
662
|
+
* outlive the enclosing compiled expression. ast_node_free
|
|
663
|
+
* returns immediately on adopted subtrees; the registry holds
|
|
664
|
+
* them for the process lifetime (bounded by the distinct closure
|
|
665
|
+
* bodies the process synthesizes). */
|
|
666
|
+
uint8_t adopted;
|
|
659
667
|
} XPathASTNode;
|
|
660
668
|
|
|
661
669
|
/* XPath parser - Matches ext/leptris/xpath.h _xpath_parser */
|
|
@@ -132,10 +132,14 @@ static int try_fold_constant_function(CompilerState* st, XPathASTNode* node) {
|
|
|
132
132
|
|
|
133
133
|
for (size_t i = 0; i < nargs; i++) {
|
|
134
134
|
XPathASTNode* a = node->children[i];
|
|
135
|
-
|
|
135
|
+
/* Finding 6 (the fold crasher, xslt_astcache_uaf_fold.bin):
|
|
136
|
+
* NUMBER literals carry NULL value — the number rides
|
|
137
|
+
* number_value — and every fold below strlens ->value, so a
|
|
138
|
+
* numeric argument crashed strlen(NULL). The fold is a
|
|
139
|
+
* STRING-literal optimization; numbers go the generic path. */
|
|
140
|
+
if (!a || a->type != XPATH_AST_STRING || !a->value) {
|
|
136
141
|
return 0;
|
|
137
142
|
}
|
|
138
|
-
if (a->type == XPATH_AST_STRING && !a->value) return 0;
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
if (strcmp(name, "concat") == 0) {
|
|
@@ -1800,6 +1800,12 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1800
1800
|
* synthetic nodes strlen-wise — a truncated closure made the
|
|
1801
1801
|
* call memcpy read past the buffer (ASAN heap-overflow). */
|
|
1802
1802
|
XPathASTNode* body = ast->children[0];
|
|
1803
|
+
/* Finding 6, part 3: ADOPT the body before its address
|
|
1804
|
+
* escapes into the carrier — the registry flags the subtree
|
|
1805
|
+
* (ast_node_free skips it) so the carrier stays invocable no
|
|
1806
|
+
* matter when the enclosing compiled expression dies. The
|
|
1807
|
+
* node is not moved; the hex address below is unchanged. */
|
|
1808
|
+
xpath_ast_cache_adopt(body);
|
|
1803
1809
|
len += (size_t)snprintf(content + len, 17, "%016llx",
|
|
1804
1810
|
(unsigned long long)(uintptr_t)body);
|
|
1805
1811
|
cap = len + 2; /* snprintf may have needed more than 17 */
|
|
@@ -1822,9 +1828,15 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1822
1828
|
evaluate_expr(ctx, ast->children[0]);
|
|
1823
1829
|
if (!callee) return NULL;
|
|
1824
1830
|
const char* cc = NULL;
|
|
1831
|
+
/* Only a TEXT node carries the carrier protocol — the blind
|
|
1832
|
+
* cast read element/attribute bytes as a content pointer and
|
|
1833
|
+
* strncmp dereferenced wild memory (nightly 43980029629,
|
|
1834
|
+
* crash-b865a005, "node()()"). */
|
|
1825
1835
|
if (callee->type == XPATH_RESULT_NODESET &&
|
|
1826
1836
|
callee->value.nodeset_value &&
|
|
1827
|
-
callee->value.nodeset_value->count > 0
|
|
1837
|
+
callee->value.nodeset_value->count > 0 &&
|
|
1838
|
+
XPATH_NODE_TYPE(callee->value.nodeset_value->nodes[0]) ==
|
|
1839
|
+
LEPTRIS_NODE_TEXT)
|
|
1828
1840
|
cc = ((XPathTextNode*)
|
|
1829
1841
|
callee->value.nodeset_value->nodes[0])->content;
|
|
1830
1842
|
if (!cc) {
|
|
@@ -171,12 +171,20 @@ static XPathASTNode* ast_node_new(XPathASTType type) {
|
|
|
171
171
|
* every name test on gcc/Linux CI). */
|
|
172
172
|
node->local_hash = 0;
|
|
173
173
|
node->local_hash_set = 0;
|
|
174
|
+
/* Finding 6: same load-bearing-init rule — garbage `adopted`
|
|
175
|
+
* would make ast_node_free silently leak the node. */
|
|
176
|
+
node->adopted = 0;
|
|
174
177
|
|
|
175
178
|
return node;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
void ast_node_free(XPathASTNode* node) {
|
|
179
182
|
if (!node) return;
|
|
183
|
+
/* SOTA C1 finding 6: an adopted subtree (the FN-carrier adoption
|
|
184
|
+
* registry owns a closure body whose carrier outlives the
|
|
185
|
+
* enclosing compiled expression) is skipped wholesale — the
|
|
186
|
+
* registry holds it for the process lifetime. */
|
|
187
|
+
if (node->adopted) return;
|
|
180
188
|
|
|
181
189
|
if (node->value) {
|
|
182
190
|
LEPTRIS_FREE(node->value);
|
|
@@ -75,6 +75,18 @@ void xpath_ast_cache_owner_end(int prev) {
|
|
|
75
75
|
}
|
|
76
76
|
#define XPATH_CACHE_OWNED (g_cache_owner_active)
|
|
77
77
|
|
|
78
|
+
/* SOTA C1 finding 6: the FN-carrier adoption registry. A closure
|
|
79
|
+
* body adopted by xpath_ast_cache_adopt is flagged `adopted` (its
|
|
80
|
+
* subtree skips ast_node_free) and listed here for the PROCESS
|
|
81
|
+
* lifetime — the carrier embedding its address may be invoked at
|
|
82
|
+
* any point later, so the body cannot be reclaimed. Bounded by the
|
|
83
|
+
* distinct closure bodies the process synthesizes. */
|
|
84
|
+
typedef struct adopted_body {
|
|
85
|
+
struct adopted_body* next;
|
|
86
|
+
XPathASTNode* body;
|
|
87
|
+
} adopted_body;
|
|
88
|
+
static adopted_body* g_adopted;
|
|
89
|
+
|
|
78
90
|
/* FNV-1a 32-bit hash. */
|
|
79
91
|
static unsigned xpath_hash(const char* s, size_t len) {
|
|
80
92
|
unsigned h = 2166136261u;
|
|
@@ -303,6 +315,30 @@ void xpath_ast_cache_release(XPathASTNode* ast) {
|
|
|
303
315
|
LEPTRIS_MUTEX_UNLOCK(&g_cache_mutex);
|
|
304
316
|
}
|
|
305
317
|
|
|
318
|
+
/* SOTA C1 finding 6, part 3: adopt a closure body for the FN
|
|
319
|
+
* carrier. Marks the subtree `adopted` (ast_node_free skips it) and
|
|
320
|
+
* lists it in g_adopted, so the carrier's embedded address stays
|
|
321
|
+
* valid no matter when its enclosing compiled expression dies.
|
|
322
|
+
* Idempotent per node — re-synthesis of the same closure is a
|
|
323
|
+
* no-op. The node is NOT moved; the carrier's hex address remains
|
|
324
|
+
* the node's address. */
|
|
325
|
+
void xpath_ast_cache_adopt(XPathASTNode* body) {
|
|
326
|
+
if (!body || body->adopted) return;
|
|
327
|
+
LEPTRIS_MUTEX_LOCK(&g_cache_mutex);
|
|
328
|
+
for (adopted_body* a = g_adopted; a; a = a->next)
|
|
329
|
+
if (a->body == body) {
|
|
330
|
+
LEPTRIS_MUTEX_UNLOCK(&g_cache_mutex);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
adopted_body* a = (adopted_body*)malloc(sizeof(*a));
|
|
334
|
+
if (!a) { LEPTRIS_MUTEX_UNLOCK(&g_cache_mutex); return; }
|
|
335
|
+
a->body = body;
|
|
336
|
+
a->next = g_adopted;
|
|
337
|
+
g_adopted = a;
|
|
338
|
+
body->adopted = 1;
|
|
339
|
+
LEPTRIS_MUTEX_UNLOCK(&g_cache_mutex);
|
|
340
|
+
}
|
|
341
|
+
|
|
306
342
|
LeptrisXPathBytecode* xpath_ast_cache_get_bc(const char* expr, size_t expr_len) {
|
|
307
343
|
if (XPATH_CACHE_OWNED) return cache_get_bc_locked(expr, expr_len);
|
|
308
344
|
LEPTRIS_MUTEX_LOCK(&g_cache_mutex);
|
|
@@ -61,6 +61,43 @@ LEPTRIS_API LeptrisXPathCompiled leptris_xpath_compile(const char* expression) {
|
|
|
61
61
|
return c;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/* The pinned bytecode borrow (libxslt bug-147, PR #600): the raw
|
|
65
|
+
* get_bc returns an UNPINNED pointer — a re-entrant store during the
|
|
66
|
+
* run can evict the slot and free the bytecode under a live VM frame
|
|
67
|
+
* whose constants hold cache-AST pointers. The ns-context eval path
|
|
68
|
+
* has run through this since #600; the fast path below ran its VM on
|
|
69
|
+
* the raw pointer and the nightly drove exactly that race (SOTA C1
|
|
70
|
+
* finding 6: UAF at evaluate_function_call_impl via the FN carrier's
|
|
71
|
+
* cache-AST constants). Every eval path goes through here. */
|
|
72
|
+
static struct leptris_xpath_result* compiled_eval_bc_pinned(
|
|
73
|
+
LeptrisXPathCompiled compiled, XPathContext* xpath_ctx) {
|
|
74
|
+
struct leptris_xpath_result* result = NULL;
|
|
75
|
+
XPathCacheEntry ce;
|
|
76
|
+
int hit = xpath_ast_cache_get(compiled->expr, compiled->expr_len,
|
|
77
|
+
&ce);
|
|
78
|
+
LeptrisXPathBytecode* bc = hit ? ce.bc : NULL;
|
|
79
|
+
if (hit && !bc) {
|
|
80
|
+
bc = leptris_xpath_compile_ast(compiled->ast);
|
|
81
|
+
if (bc) {
|
|
82
|
+
xpath_ast_cache_store_bc(compiled->expr,
|
|
83
|
+
compiled->expr_len, bc);
|
|
84
|
+
/* #1079: a twin compile may have won the slot and store
|
|
85
|
+
* freed OUR bytecode as the loser — re-read the canonical
|
|
86
|
+
* cached bytecode for the run (the entry is pinned, so it
|
|
87
|
+
* cannot be evicted here). */
|
|
88
|
+
LeptrisXPathBytecode* canonical = xpath_ast_cache_get_bc(
|
|
89
|
+
compiled->expr, compiled->expr_len);
|
|
90
|
+
if (canonical) bc = canonical;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (bc) {
|
|
94
|
+
result = leptris_xpath_vm_run_bc(bc, xpath_ctx);
|
|
95
|
+
if (!result) xpath_ctx->error_msg[0] = '\0';
|
|
96
|
+
}
|
|
97
|
+
if (hit) xpath_ast_cache_release(ce.ast);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
64
101
|
/* Run a compiled expression against a PREPARED context (the XSLT
|
|
65
102
|
* bridge installs its own function registry + variable set before
|
|
66
103
|
* calling this). VM fast path first; AST interpreter fallback. The
|
|
@@ -68,18 +105,8 @@ LEPTRIS_API LeptrisXPathCompiled leptris_xpath_compile(const char* expression) {
|
|
|
68
105
|
struct leptris_xpath_result* leptris_xpath_compiled_eval_in(
|
|
69
106
|
LeptrisXPathCompiled compiled, XPathContext* xpath_ctx) {
|
|
70
107
|
if (!compiled || !xpath_ctx || !xpath_ctx->document) return NULL;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
struct leptris_xpath_result* result = NULL;
|
|
74
|
-
if (bc) {
|
|
75
|
-
result = leptris_xpath_vm_run_bc(bc, xpath_ctx);
|
|
76
|
-
} else {
|
|
77
|
-
bc = leptris_xpath_compile_ast(compiled->ast);
|
|
78
|
-
if (bc) {
|
|
79
|
-
result = leptris_xpath_vm_run_bc(bc, xpath_ctx);
|
|
80
|
-
xpath_ast_cache_store_bc(compiled->expr, compiled->expr_len, bc);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
108
|
+
struct leptris_xpath_result* result =
|
|
109
|
+
compiled_eval_bc_pinned(compiled, xpath_ctx);
|
|
83
110
|
if (!result) result = xpath_evaluate(xpath_ctx, compiled->ast);
|
|
84
111
|
|
|
85
112
|
if (!result && xpath_ctx->error_msg[0]) {
|
|
@@ -152,35 +179,8 @@ static struct leptris_xpath_result* compiled_eval_context(
|
|
|
152
179
|
* The earlier bug-76 divergence was the position-predicate
|
|
153
180
|
* absolute tail — which never merged; position predicates on
|
|
154
181
|
* absolute paths stay on the interpreter path. */
|
|
155
|
-
struct leptris_xpath_result* result =
|
|
156
|
-
|
|
157
|
-
/* Pinned borrow (the raw get_bc returns an unpinned pointer —
|
|
158
|
-
* a re-entrant store during the run can evict and free it;
|
|
159
|
-
* ASAN caught exactly that in libxslt bug-147, PR #600). */
|
|
160
|
-
XPathCacheEntry ce;
|
|
161
|
-
int hit = xpath_ast_cache_get(compiled->expr, compiled->expr_len,
|
|
162
|
-
&ce);
|
|
163
|
-
LeptrisXPathBytecode* bc = hit ? ce.bc : NULL;
|
|
164
|
-
if (hit && !bc) {
|
|
165
|
-
bc = leptris_xpath_compile_ast(compiled->ast);
|
|
166
|
-
if (bc) {
|
|
167
|
-
xpath_ast_cache_store_bc(compiled->expr,
|
|
168
|
-
compiled->expr_len, bc);
|
|
169
|
-
/* #1079: a twin compile may have won the slot and
|
|
170
|
-
* store freed OUR bytecode as the loser — re-read
|
|
171
|
-
* the canonical cached bytecode for the run (the
|
|
172
|
-
* entry is pinned, so it cannot be evicted here). */
|
|
173
|
-
LeptrisXPathBytecode* canonical = xpath_ast_cache_get_bc(
|
|
174
|
-
compiled->expr, compiled->expr_len);
|
|
175
|
-
if (canonical) bc = canonical;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (bc) {
|
|
179
|
-
result = leptris_xpath_vm_run_bc(bc, xpath_ctx);
|
|
180
|
-
if (!result) xpath_ctx->error_msg[0] = '\0';
|
|
181
|
-
}
|
|
182
|
-
if (hit) xpath_ast_cache_release(ce.ast);
|
|
183
|
-
}
|
|
182
|
+
struct leptris_xpath_result* result =
|
|
183
|
+
compiled_eval_bc_pinned(compiled, xpath_ctx);
|
|
184
184
|
if (!result)
|
|
185
185
|
result = xpath_evaluate(xpath_ctx, compiled->ast);
|
|
186
186
|
|
|
@@ -95,6 +95,13 @@ void xpath_ast_cache_owner_end(int prev);
|
|
|
95
95
|
XPathASTNode* xpath_ast_cache_insert(const char* expr, size_t expr_len, XPathASTNode* ast);
|
|
96
96
|
void xpath_ast_cache_release(XPathASTNode* ast);
|
|
97
97
|
|
|
98
|
+
/* SOTA C1 finding 6: adopt a closure body for the FN carrier — flags
|
|
99
|
+
* the subtree `adopted` (ast_node_free skips it) and lists it in the
|
|
100
|
+
* process-lifetime registry, so the carrier's embedded address stays
|
|
101
|
+
* valid past its enclosing compiled expression's death. Idempotent
|
|
102
|
+
* per node; the node is not moved. */
|
|
103
|
+
void xpath_ast_cache_adopt(XPathASTNode* body);
|
|
104
|
+
|
|
98
105
|
/* Combined lookup (TODO 159 Phase E drive-by): single hash + scan
|
|
99
106
|
* that returns both the AST and the bytecode in one pass. Replaces
|
|
100
107
|
* the previous two-call pattern (xpath_ast_cache_lookup +
|
|
@@ -525,6 +525,56 @@ static void xslt_avt_free(XsltExec* ex) {
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
+
/* Compile onto the exec-lifetime chain (finding 6, SOTA C1): the FN
|
|
529
|
+
* carrier's body is borrowed from its enclosing compiled expression,
|
|
530
|
+
* and a carrier can survive in a variable binding past that
|
|
531
|
+
* expression's natural scope. Transient compiles at the three
|
|
532
|
+
* dynamic sites (op_evaluate, the apply-imports caller-param loop,
|
|
533
|
+
* the @* pattern probe) therefore promote to transform lifetime —
|
|
534
|
+
* the v1 carrier contract ("borrowed ... transform-lifetime")
|
|
535
|
+
* becomes true instead of assumed. */
|
|
536
|
+
typedef struct CompiledChain {
|
|
537
|
+
struct CompiledChain* next;
|
|
538
|
+
LeptrisXPathCompiled c;
|
|
539
|
+
char* expr;
|
|
540
|
+
} CompiledChain;
|
|
541
|
+
|
|
542
|
+
static LeptrisXPathCompiled xslt_exec_compile(XsltExec* ex,
|
|
543
|
+
const char* expr) {
|
|
544
|
+
/* Same text compiles once per transform (the AVT cache rule) —
|
|
545
|
+
* the @* probe dispatches per node and must not grow the chain. */
|
|
546
|
+
for (CompiledChain* e = (CompiledChain*)ex->compiled_cache; e;
|
|
547
|
+
e = e->next)
|
|
548
|
+
if (strcmp(e->expr, expr) == 0) return e->c;
|
|
549
|
+
LeptrisXPathCompiled c = leptris_xpath_compile(expr);
|
|
550
|
+
if (!c) return NULL;
|
|
551
|
+
CompiledChain* link = (CompiledChain*)malloc(sizeof(*link));
|
|
552
|
+
if (!link) {
|
|
553
|
+
leptris_xpath_compiled_free(c);
|
|
554
|
+
return NULL;
|
|
555
|
+
}
|
|
556
|
+
link->expr = leptris_strdup(expr);
|
|
557
|
+
if (!link->expr) {
|
|
558
|
+
free(link);
|
|
559
|
+
leptris_xpath_compiled_free(c);
|
|
560
|
+
return NULL;
|
|
561
|
+
}
|
|
562
|
+
link->c = c;
|
|
563
|
+
link->next = (CompiledChain*)ex->compiled_cache;
|
|
564
|
+
ex->compiled_cache = link;
|
|
565
|
+
return c;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
static void xslt_compiled_cache_free(XsltExec* ex) {
|
|
569
|
+
while (ex->compiled_cache) {
|
|
570
|
+
CompiledChain* e = (CompiledChain*)ex->compiled_cache;
|
|
571
|
+
ex->compiled_cache = e->next;
|
|
572
|
+
leptris_xpath_compiled_free(e->c);
|
|
573
|
+
free(e->expr);
|
|
574
|
+
free(e);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
528
578
|
/* Evaluate an attribute-value template: "a{expr}b" pieces are
|
|
529
579
|
* concatenated; {{ and }} are literal braces (§7.1.1). */
|
|
530
580
|
static char* eval_avt(XsltExec* ex, const char* tmpl, LeptrisElement node) {
|
|
@@ -1315,7 +1365,7 @@ static int op_evaluate(XsltExec* ex, const XsltInstr* in,
|
|
|
1315
1365
|
char* expr = leptris_xpath_result_string(xr);
|
|
1316
1366
|
leptris_xpath_result_free(xr);
|
|
1317
1367
|
if (!expr) return 0;
|
|
1318
|
-
LeptrisXPathCompiled c =
|
|
1368
|
+
LeptrisXPathCompiled c = xslt_exec_compile(ex, expr);
|
|
1319
1369
|
free(expr);
|
|
1320
1370
|
if (!c) return 0;
|
|
1321
1371
|
LeptrisElement ctx = NULL;
|
|
@@ -1347,7 +1397,8 @@ static int op_evaluate(XsltExec* ex, const XsltInstr* in,
|
|
|
1347
1397
|
}
|
|
1348
1398
|
struct leptris_xpath_result* r = ctx ? xslt_eval(ex, c, ctx) : NULL;
|
|
1349
1399
|
xslt_pop_vars_to(ex, scope_mark);
|
|
1350
|
-
|
|
1400
|
+
/* c rides the exec-lifetime chain (finding 6): its AST may hold
|
|
1401
|
+
* a closure whose carrier escaped into a with-param binding. */
|
|
1351
1402
|
if (!r) return 0;
|
|
1352
1403
|
char* sv = value_of_string(ex, r);
|
|
1353
1404
|
leptris_xpath_result_free(r);
|
|
@@ -3493,7 +3544,7 @@ static int builtin_no_match(XsltExec* ex, const char* mode,
|
|
|
3493
3544
|
* the attribute templates operate on; the element's raw
|
|
3494
3545
|
* attribute records do not share that layout. */
|
|
3495
3546
|
{
|
|
3496
|
-
LeptrisXPathCompiled at =
|
|
3547
|
+
LeptrisXPathCompiled at = xslt_exec_compile(ex, "@*");
|
|
3497
3548
|
if (at) {
|
|
3498
3549
|
struct leptris_xpath_result* ar = xslt_eval(ex, at, node);
|
|
3499
3550
|
size_t an = ar ? leptris_xpath_result_count(ar) : 0;
|
|
@@ -3506,7 +3557,6 @@ static int builtin_no_match(XsltExec* ex, const char* mode,
|
|
|
3506
3557
|
rc = xslt_invoke_template(ex, best, a, NULL);
|
|
3507
3558
|
}
|
|
3508
3559
|
if (ar) leptris_xpath_result_free(ar);
|
|
3509
|
-
leptris_xpath_compiled_free(at);
|
|
3510
3560
|
}
|
|
3511
3561
|
}
|
|
3512
3562
|
if (rc) return rc;
|
|
@@ -4844,6 +4894,7 @@ void xslt_exec_free(XsltExec* ex) {
|
|
|
4844
4894
|
xslt_ufn_free(ex);
|
|
4845
4895
|
xslt_gids_free(ex);
|
|
4846
4896
|
xslt_avt_free(ex);
|
|
4897
|
+
xslt_compiled_cache_free(ex);
|
|
4847
4898
|
if (ex->fn_result) leptris_xpath_result_free(ex->fn_result);
|
|
4848
4899
|
while (ex->vars) xslt_pop_var(ex, NULL);
|
|
4849
4900
|
if (ex->caller_param_names) {
|
|
@@ -4961,10 +5012,11 @@ static XsltExec* transform_doc_ex(const XsltStylesheet* sheet,
|
|
|
4961
5012
|
ex->eval_error = 1;
|
|
4962
5013
|
break;
|
|
4963
5014
|
}
|
|
4964
|
-
LeptrisXPathCompiled c =
|
|
5015
|
+
LeptrisXPathCompiled c = xslt_exec_compile(ex, expr);
|
|
4965
5016
|
if (!c) { ex->eval_error = 1; break; }
|
|
4966
5017
|
struct leptris_xpath_result* v = xslt_eval(ex, c, globals_ctx);
|
|
4967
|
-
|
|
5018
|
+
/* c rides the exec-lifetime chain (finding 6): the carrier
|
|
5019
|
+
* it produced is about to become a caller binding. */
|
|
4968
5020
|
if (!v) { ex->eval_error = 1; break; }
|
|
4969
5021
|
xslt_push_var(ex, ex->caller_param_names[i], v);
|
|
4970
5022
|
/* keep the §11 call-template reset point current while
|
|
@@ -741,6 +741,16 @@ typedef struct xslt_exec {
|
|
|
741
741
|
* expression text). Freed by xslt_exec_free. */
|
|
742
742
|
void* avt_cache;
|
|
743
743
|
|
|
744
|
+
/* xslt_exec.c: TRANSIENT compiled expressions promoted to
|
|
745
|
+
* exec-lifetime (finding 6, SOTA C1). The FN carrier's body is
|
|
746
|
+
* borrowed from its enclosing compiled expression — the carrier
|
|
747
|
+
* may survive in a variable binding past the borrowing expr's
|
|
748
|
+
* natural scope (op_evaluate's dynamic compile, the
|
|
749
|
+
* apply-imports caller-param loop, the @* pattern probe), so
|
|
750
|
+
* those compiles move onto this chain and free at transform end
|
|
751
|
+
* like the AVT cache. Freed by xslt_exec_free. */
|
|
752
|
+
void* compiled_cache;
|
|
753
|
+
|
|
744
754
|
/* RTF ownership chain: result-tree-fragment documents built by
|
|
745
755
|
* <xsl:variable> bodies whose lifetime must outlive the
|
|
746
756
|
* nodeset that references their nodes (§11.4 — the spec calls
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="node[@status]/b"><xsl:for-each select="r/r[@mode][x]/descendant::b[@mode]|descendant::node[@sku]|out[@mode]/leaf"><xsl:value-of select="number(@id)"/><xsl:value-of select="normalize-space(.)"/><xsl:value-of select="number(@id)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:if test="a/r[42]/span"><xsl:if test="3.5 > 0"><xsl:value-of select="concat('x',.)"/><xsl:value-of select="contains(@kind,'x')"/><out>@status</out></xsl:if><xsl:for-each select="*/a/leaf"><xsl:sort select="-7"/><node>@status</node><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:if><xsl:if test="(true())"><xsl:for-each select="leaf[0]|//leaf/child::a[-7]/node|child::out/descendant::item/item"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="round(number(@id))"/></xsl:for-each></xsl:if><xsl:if test="a[@status]/leaf[true() + 42]"><leaf>@status</leaf><xsl:for-each select="child::span[@id][0]|item[0]/out[@id][x]/node[@id]"><xsl:value-of select="string-length(.)"/><xsl:value-of select="string-length(.)"/><xsl:value-of select="concat('x',.)"/></xsl:for-each></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="contains(@kind,'x')"/><xsl:for-each select="leaf/leaf/following-sibling::span|*[child::a/following-sibling::node[@mode]/node]/item[string-length(.)]/*[@mode]|following-sibling::out/span[@id]"><xsl:if test="a[3.5]"><xsl:value-of select="span[@mode]"/></xsl:if></xsl:for-each><xsl:if test="-7"><xsl:for-each select="*[@status][0]/item[@id]"><xsl:sort select="//leaf[@sku]/b/span[@id]"/><xsl:value-of select="starts-with(name(),'a')"/></xsl:for-each></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="following-sibling::node[@mode]/a[@kind]|ancestor::leaf/following-sibling::out|*/r[@id][3.5]"><xsl:value-of select="number(@id)"/><r>@id</r></xsl:for-each><xsl:if test="descendant::r/*[@kind]"><xsl:for-each select="out/a[@mode][true()]"><xsl:sort select="true()"/><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:if><xsl:for-each select="b[@mode][position()]/span[@sku]/descendant::b[42 * 0]"><xsl:value-of select="normalize-space(.)"/></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="leaf/*[@sku]/a[@status]"><node>@sku</node></xsl:for-each><node>@status</node></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="a[@id]/descendant::b/*|leaf[@status]/leaf[@kind]/span[@kind]|b[@sku][(-7)]"><xsl:if test="true() + 42"><xsl:value-of select="concat('x',.)"/><xsl:value-of select="starts-with(name(),'a')"/><xsl:value-of select="string-length(.)"/></xsl:if></xsl:for-each><xsl:if test="r[-7]"><xsl:value-of select="number(@id)"/><xsl:for-each select="*[@status]/leaf"><xsl:sort select="substring(.,1,2)"/><xsl:value-of select="round(number(@id))"/></xsl:for-each></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="b|child::item|out[@status]/item/leaf[0]"><xsl:value-of select="number(@id)"/></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="*/descendant::item[*/item]/following-sibling::leaf"><xsl:for-each select="*[@kind][0]/child::a[@id]"><xsl:value-of select="number(@id)"/><out>@mode</out></xsl:for-each></xsl:for-each><item>@kind</item></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="item/r[@mode][last()]|//descendant::node[@mode]/b[@sku]"><xsl:value-of select="concat('x',.)"/></xsl:for-each><xsl:value-of select="round(number(@id))"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="normalize-space(.)"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="a[@id][//r[-7]/b/out[-7]]/span[@mode]|*/child::r[true() != -7]/r|descendant::leaf[@id]"><xsl:for-each select="span/following-sibling::a[@mode][3.5]"><xsl:value-of select="string-length(.)"/><r>@id</r><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:for-each><xsl:for-each select="descendant::leaf[x + true()]|following-sibling::leaf[b[@id]/descendant::a/following-sibling::span[@kind][42]]|a"><xsl:value-of select="number(@id)"/><node>@sku</node></xsl:for-each><xsl:for-each select="//node[-7 - 0]/child::a/a"><xsl:value-of select="contains(@kind,'x')"/></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><b>@status</b></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="*|span/child::item[@sku][*[@sku][-7]/b]"><xsl:if test="*[@mode][0]/node"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="//out/node[@kind]"/></xsl:if></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="a[@status]/*[@sku]/r|//out[x]|node[@kind]/r[(-7)]"><xsl:for-each select="out[@kind]/descendant::leaf[@id]/descendant::a[@status]|a[true()]/r/span[0]"><xsl:value-of select="concat('x',.)"/><xsl:value-of select="number(@id)"/></xsl:for-each><xsl:for-each select="*[@kind]/*"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="substring(.,1,2)"/></xsl:for-each><xsl:if test="0"><xsl:value-of select="normalize-space(.)"/><xsl:value-of select="round(number(@id))"/></xsl:if></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="child::out[@mode]/child::item/span"><xsl:sort select="out/child::* != leaf[@sku]/out[@kind]"/><xsl:if test="out/item"><item>@sku</item><xsl:value-of select="starts-with(name(),'a')"/></xsl:if><xsl:for-each select="*[@status][0]/a[@id]"><xsl:sort select="true()"/><xsl:value-of select="number(@id)"/></xsl:for-each><xsl:for-each select="//span|node[@mode]"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="round(number(@id))"/><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:for-each><out>@status</out><leaf>@kind</leaf></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="leaf[@id]/node[@id]/a|leaf[@sku]/child::*[true() != true()]/ancestor::leaf"><xsl:for-each select="//following-sibling::span/*/span|descendant::leaf/node[0]"><r>@kind</r><span>@sku</span><xsl:value-of select="contains(@kind,'x')"/></xsl:for-each></xsl:for-each><xsl:if test="last()"><xsl:value-of select="substring(.,1,2)"/><xsl:for-each select="span[@status][42]|*[@status][true()]|out"><leaf>@sku</leaf></xsl:for-each></xsl:if><xsl:value-of select="string-length(.)"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="concat('x',.)"/><xsl:value-of select="normalize-space(.)"/><xsl:for-each select="item/following-sibling::*[x]/*[@mode][normalize-space(.)]|*[string-length(.)]/*[@status]/a[@sku][x]"><xsl:for-each select="span|span[3.5]"><xsl:value-of select="starts-with(name(),'a')"/><xsl:value-of select="substring(.,1,2)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><item>@status</item><xsl:for-each select="child::r[@id]/a"><xsl:sort select="//out[@sku][3.5 <= 0]/span/r[@sku]"/><xsl:for-each select="r|*[42]|b"><xsl:value-of select="number(@id)"/><xsl:value-of select="round(number(@id))"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="b[-7 = x]/r[//out[@status]]|span"><xsl:if test="(42)"><xsl:value-of select="starts-with(name(),'a')"/><xsl:value-of select="round(number(@id))"/><xsl:value-of select="normalize-space(.)"/></xsl:if><xsl:value-of select="starts-with(name(),'a')"/></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="substring(.,1,2)"/><xsl:for-each select="item/a[@kind][position()]/r"><xsl:sort select="*/child::*[@kind]"/><xsl:for-each select="node[@kind]/b/following-sibling::node[-7]"><item>@sku</item><xsl:value-of select="string-length(.)"/><span>@sku</span></xsl:for-each><xsl:for-each select="descendant::leaf/span"><xsl:value-of select="concat('x',.)"/></xsl:for-each></xsl:for-each><a>@mode</a></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><r>@sku</r><a>@kind</a></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="//*[(true())]/*[@kind]|//r/ancestor::node[@mode]"><item>@sku</item></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="normalize-space(.)"/><xsl:if test="x <= x"><xsl:value-of select="round(number(@id))"/><xsl:for-each select="child::*/node[@id][0]|child::a|*[@sku]"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:if><a>@status</a></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><span>@kind</span><xsl:if test="true()"><xsl:value-of select="contains(@kind,'x')"/></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><item>@kind</item><xsl:for-each select="*[@sku]|node[@mode]"><xsl:if test="true()"><xsl:value-of select="normalize-space(.)"/><xsl:value-of select="concat('x',.)"/><xsl:value-of select="normalize-space(.)"/></xsl:if><xsl:value-of select="round(number(@id))"/><leaf>@kind</leaf></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="b|//child::node[@mode]/leaf[3.5 > 0]/node[(3.5)]"><xsl:for-each select="descendant::leaf/ancestor::span[@kind]/leaf"><xsl:value-of select="round(number(@id))"/><xsl:value-of select="number(@id)"/><xsl:value-of select="round(number(@id))"/></xsl:for-each><xsl:for-each select="a[@mode][3.5]|span[@id]"><xsl:value-of select="contains(@kind,'x')"/><xsl:value-of select="round(number(@id))"/><xsl:value-of select="number(@id)"/></xsl:for-each><xsl:for-each select="//leaf/leaf[@sku]/leaf[@id]|descendant::node|descendant::r[@mode]/*/b[@mode]"><xsl:value-of select="out[0]/span[@status]/descendant::r"/><xsl:value-of select="substring(.,1,2)"/></xsl:for-each></xsl:for-each><xsl:for-each select="//r[@id][42]/r|node/out/*"><xsl:if test="42 >= -7"><xsl:value-of select="normalize-space(.)"/><out>@id</out></xsl:if><a>@mode</a></xsl:for-each><xsl:value-of select="concat('x',.)"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="leaf/node[@status][-7 > true()]/r"><r>@mode</r><xsl:for-each select="span/b/r|//b|following-sibling::out[@sku]"><r>@status</r><xsl:value-of select="normalize-space(.)"/><xsl:value-of select="starts-with(name(),'a')"/></xsl:for-each><xsl:value-of select="concat('x',.)"/></xsl:for-each><xsl:for-each select="r[string-length(.)]/leaf/leaf[-7]"><xsl:if test="x"><xsl:value-of select="r[true()]"/></xsl:if></xsl:for-each><xsl:for-each select="node/item[@sku]/r"><xsl:sort select="x"/><xsl:for-each select="leaf[-7]/b[0]|a[@id]/a"><xsl:value-of select="normalize-space(.)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:if test="(following-sibling::out/descendant::out)"><leaf>@mode</leaf></xsl:if><xsl:for-each select="r[@status]|leaf[@sku]/node"><out>@mode</out><xsl:value-of select="concat('x',.)"/><xsl:for-each select="ancestor::leaf|a[@sku]/*[x]/node|//leaf/item/out"><xsl:value-of select="normalize-space(.)"/></xsl:for-each></xsl:for-each><xsl:if test="position() < x"><xsl:value-of select="number(@id)"/></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="normalize-space(.)"/><xsl:for-each select="b[@kind]"><xsl:sort select="-7 mod *[x]"/><xsl:value-of select="number(@id)"/></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><leaf>@sku</leaf><xsl:value-of select="concat('x',.)"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><span>@sku</span></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:if test="a[@status]"><xsl:if test="-7 < 0"><xsl:value-of select="normalize-space(.)"/></xsl:if><xsl:for-each select="span[3.5]/child::item|child::out/r[-7]/r[@status]|b[@mode]/following-sibling::out"><xsl:value-of select="string-length(.)"/></xsl:for-each><xsl:for-each select="//node/out[@kind][42]/b|a/ancestor::r/leaf|descendant::*[@mode][0]/item[@mode]"><a>@kind</a></xsl:for-each></xsl:if><xsl:for-each select="//ancestor::r/ancestor::node/leaf[@id]"><xsl:for-each select="//b/*[@mode][true()]"><xsl:sort select="normalize-space(.)"/><xsl:value-of select="starts-with(name(),'a')"/><xsl:value-of select="contains(@kind,'x')"/></xsl:for-each><xsl:value-of select="round(number(@id))"/><node>@kind</node></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><leaf>@sku</leaf><xsl:for-each select="node/a[@kind]/span[@id]|//leaf[@mode]/descendant::node[@status]/r[(-7)]"><xsl:value-of select="string-length(.)"/><xsl:if test="(3.5)"><xsl:value-of select="round(number(@id))"/><item>@status</item><xsl:value-of select="concat('x',.)"/></xsl:if><xsl:for-each select="r[@kind]"><xsl:sort select="true()"/><xsl:value-of select="a/leaf"/><xsl:value-of select="number(@id)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="normalize-space(.)"/><xsl:if test="starts-with(name(),'a')"><xsl:for-each select="b[0]|*/span[@kind]|//a"><xsl:value-of select="number(@id)"/><node>@status</node><span>@id</span></xsl:for-each><xsl:value-of select="string-length(.)"/></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:if test="x mod 3.5 >= 42"><xsl:for-each select="item[@status]/descendant::leaf[@id][3.5]|out[-7]|//out/descendant::span[0]/descendant::span"><xsl:value-of select="contains(@kind,'x')"/><xsl:value-of select="normalize-space(.)"/><out>@id</out></xsl:for-each><xsl:for-each select="r/*[@kind]/r[@mode]|//a[@kind]/child::*[@mode]/ancestor::leaf[@status]"><xsl:value-of select="string-length(.)"/><item>@kind</item></xsl:for-each><xsl:value-of select="concat('x',.)"/></xsl:if><xsl:for-each select="//*[x]/span/child::*|span[@sku]"><xsl:value-of select="round(number(@id))"/><xsl:for-each select="*/ancestor::*/item|child::span[@mode][-7]/a[@sku][x]"><xsl:value-of select="normalize-space(.)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="starts-with(name(),'a')"/><node>@kind</node></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:if test="item[(true())]/*[@kind]/a[@kind]"><out>@id</out><xsl:if test="0"><xsl:value-of select="number(@id)"/><xsl:value-of select="normalize-space(.)"/><xsl:value-of select="concat('x',.)"/></xsl:if><leaf>@mode</leaf></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><node>@mode</node><xsl:if test="0"><xsl:for-each select="leaf[0]|a[42]/ancestor::*"><xsl:value-of select="number(@id)"/><r>@kind</r></xsl:for-each></xsl:if><xsl:if test="x > 0 < 3.5"><b>@status</b></xsl:if></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="descendant::b[@kind]/b"><xsl:sort select="last()"/><a>@kind</a><xsl:if test="-7"><xsl:value-of select="normalize-space(.)"/></xsl:if></xsl:for-each><b>@status</b><xsl:for-each select="//*[@sku]/item/b[@status][3.5 mod true()]|//item/item[true()]/ancestor::span"><xsl:for-each select="*/ancestor::span"><xsl:value-of select="substring(.,1,2)"/></xsl:for-each></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:for-each select="//span/b|child::r[@status]|*[42 * 0]/r/*"><out>@id</out></xsl:for-each></xsl:template></xsl:stylesheet>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:value-of select="concat('x',.)"/><xsl:for-each select="descendant::span/child::node[@status]/span[@status][-7]"><xsl:sort select="string-length(.)"/><xsl:for-each select="a[-7]/*[3.5]|node[@mode]/descendant::a/span[true()]"><xsl:valua-of select="normalize-space(.)"/></xsl:for-each><xsl:for-each select="out[0]/item[@kind][42]|span[@sku][-7]|child::*/node[0]"><xsl:value-of select="contains(@kind,'x')"/><xsl:value-of select="string-length(.)"/></xsl:for-each></xsl:for-each><xsl:value-of select="substring(.,1,2)"/></xsl:template></xsl:stylesheet>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Grammar-aware seed generator for the XSLT/XPath fuzz families
|
|
3
|
+
(SOTA C1 #2051). Pure mutation from flat seeds reaches expression
|
|
4
|
+
STRUCTURE slowly; this generator composes valid-but-deep stylesheets
|
|
5
|
+
— paths, unions, predicates, arithmetic, function calls, sorts,
|
|
6
|
+
nested constructors — from a fixed vocabulary, giving libFuzzer
|
|
7
|
+
coverage anchors at expression depths mutation cannot build.
|
|
8
|
+
|
|
9
|
+
Each seed is a complete stylesheet fed through leptris_xslt_parse by
|
|
10
|
+
the nightly's fuzz_xslt leg. Deterministic under --seed.
|
|
11
|
+
|
|
12
|
+
Usage: gen_xslt_seeds.py OUTDIR [--seed N] [--count N]
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import os
|
|
17
|
+
import random
|
|
18
|
+
|
|
19
|
+
XSL = "http://www.w3.org/1999/XSL/Transform"
|
|
20
|
+
|
|
21
|
+
NAMES = ["a", "b", "item", "r", "out", "node", "leaf", "span"]
|
|
22
|
+
ATTRS = ["id", "kind", "status", "sku", "mode"]
|
|
23
|
+
FUNCS0 = ["position()", "last()", "count(//*)"]
|
|
24
|
+
FUNCS1 = [
|
|
25
|
+
"string-length(.)",
|
|
26
|
+
"number(@id)",
|
|
27
|
+
"contains(@kind,'x')",
|
|
28
|
+
"starts-with(name(),'a')",
|
|
29
|
+
"substring(.,1,2)",
|
|
30
|
+
"normalize-space(.)",
|
|
31
|
+
"concat('x',.)",
|
|
32
|
+
"round(number(@id))",
|
|
33
|
+
]
|
|
34
|
+
AXES = ["child::", "descendant::", "following-sibling::", "ancestor::"]
|
|
35
|
+
|
|
36
|
+
TEXT_ATOMS = ["x", "42", "-7", "3.5", "true()", "0"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def gen_path(rng, depth=0):
|
|
40
|
+
"""A relative or absolute location path with optional predicates."""
|
|
41
|
+
parts = []
|
|
42
|
+
if rng.random() < 0.2:
|
|
43
|
+
parts.append("/")
|
|
44
|
+
nsteps = rng.randint(1, 3)
|
|
45
|
+
for i in range(nsteps):
|
|
46
|
+
axis = rng.choice(AXES) if rng.random() < 0.25 else ""
|
|
47
|
+
name = rng.choice(NAMES)
|
|
48
|
+
if rng.random() < 0.15:
|
|
49
|
+
name = "*"
|
|
50
|
+
step = f"{axis}{name}"
|
|
51
|
+
if rng.random() < 0.4:
|
|
52
|
+
step += f"[@{rng.choice(ATTRS)}]"
|
|
53
|
+
if rng.random() < 0.25:
|
|
54
|
+
step += f"[{gen_scalar(rng, depth + 1)}]"
|
|
55
|
+
parts.append(step)
|
|
56
|
+
return "/".join(parts)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def gen_scalar(rng, depth=0):
|
|
60
|
+
"""A scalar expression: literal, function, arithmetic, comparison."""
|
|
61
|
+
if depth > 2:
|
|
62
|
+
return rng.choice(TEXT_ATOMS)
|
|
63
|
+
r = rng.random()
|
|
64
|
+
if r < 0.25:
|
|
65
|
+
return rng.choice(TEXT_ATOMS)
|
|
66
|
+
if r < 0.40:
|
|
67
|
+
return rng.choice(FUNCS0 + FUNCS1)
|
|
68
|
+
if r < 0.55:
|
|
69
|
+
return f"{gen_scalar(rng, depth + 1)} {rng.choice(['+','-','*','div','mod'])} {gen_scalar(rng, depth + 1)}"
|
|
70
|
+
if r < 0.70:
|
|
71
|
+
return f"{gen_scalar(rng, depth + 1)} {rng.choice(['=','!=','<','>','<=','>='])} {gen_scalar(rng, depth + 1)}"
|
|
72
|
+
if r < 0.80:
|
|
73
|
+
return f"({gen_scalar(rng, depth + 1)})"
|
|
74
|
+
return gen_path(rng, depth)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def gen_union(rng, depth=0):
|
|
78
|
+
"""1-3 alternatives joined by | — the union operator's surface."""
|
|
79
|
+
n = rng.randint(1, 3)
|
|
80
|
+
return "|".join(gen_path(rng, depth) for _ in range(n))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def gen_body(rng, depth=0):
|
|
84
|
+
"""A sequence constructor fragment."""
|
|
85
|
+
out = []
|
|
86
|
+
n = rng.randint(1, 3)
|
|
87
|
+
for _ in range(n):
|
|
88
|
+
r = rng.random()
|
|
89
|
+
if depth < 2 and r < 0.35:
|
|
90
|
+
sel = gen_union(rng, depth + 1)
|
|
91
|
+
out.append(
|
|
92
|
+
f"<xsl:for-each select=\"{xml_attr(sel)}\">"
|
|
93
|
+
f"{gen_body(rng, depth + 1)}</xsl:for-each>"
|
|
94
|
+
)
|
|
95
|
+
elif depth < 2 and r < 0.5:
|
|
96
|
+
test = gen_scalar(rng, depth + 1)
|
|
97
|
+
out.append(
|
|
98
|
+
f"<xsl:if test=\"{xml_attr(test)}\">"
|
|
99
|
+
f"{gen_body(rng, depth + 1)}</xsl:if>"
|
|
100
|
+
)
|
|
101
|
+
elif depth < 2 and r < 0.6:
|
|
102
|
+
sel = gen_path(rng, depth + 1)
|
|
103
|
+
sort = gen_scalar(rng, depth + 1)
|
|
104
|
+
out.append(
|
|
105
|
+
f"<xsl:for-each select=\"{xml_attr(sel)}\">"
|
|
106
|
+
f"<xsl:sort select=\"{xml_attr(sort)}\"/>"
|
|
107
|
+
f"{gen_body(rng, depth + 1)}</xsl:for-each>"
|
|
108
|
+
)
|
|
109
|
+
elif r < 0.8:
|
|
110
|
+
sel = rng.choice(FUNCS1 + [gen_path(rng, depth + 1)])
|
|
111
|
+
out.append(f"<xsl:value-of select=\"{xml_attr(sel)}\"/>")
|
|
112
|
+
else:
|
|
113
|
+
name = rng.choice(NAMES)
|
|
114
|
+
out.append(f"<{name}>@{rng.choice(ATTRS)}</{name}>")
|
|
115
|
+
return "".join(out)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def xml_attr(s):
|
|
119
|
+
return s.replace("&", "&").replace('"', """).replace("<", "<")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def gen_stylesheet(rng):
|
|
123
|
+
"""A full stylesheet: a root template whose body exercises the
|
|
124
|
+
generated expression grammar."""
|
|
125
|
+
body = gen_body(rng)
|
|
126
|
+
return (
|
|
127
|
+
f'<xsl:stylesheet xmlns:xsl="{XSL}" version="1.0">'
|
|
128
|
+
f'<xsl:template match="/">'
|
|
129
|
+
f"{body}"
|
|
130
|
+
f"</xsl:template></xsl:stylesheet>"
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def main():
|
|
135
|
+
ap = argparse.ArgumentParser()
|
|
136
|
+
ap.add_argument("outdir")
|
|
137
|
+
ap.add_argument("--seed", type=int, default=20261117)
|
|
138
|
+
ap.add_argument("--count", type=int, default=120)
|
|
139
|
+
args = ap.parse_args()
|
|
140
|
+
|
|
141
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
142
|
+
rng = random.Random(args.seed)
|
|
143
|
+
for i in range(args.count):
|
|
144
|
+
sheet = gen_stylesheet(rng)
|
|
145
|
+
path = os.path.join(args.outdir, f"gen_{i:04d}.xsl")
|
|
146
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
147
|
+
f.write(sheet)
|
|
148
|
+
print(f"{args.count} seeds -> {args.outdir}")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
main()
|
|
@@ -2865,3 +2865,33 @@ TEST(XPathUnion, NumberHeadLeftSideYieldsEmptyNodeset) {
|
|
|
2865
2865
|
leptris_xpath_result_free(r2);
|
|
2866
2866
|
leptris_document_free(doc);
|
|
2867
2867
|
}
|
|
2868
|
+
|
|
2869
|
+
/* SOTA C1 (nightly 43980029629, crash-b865a005, fuzz_xslt): a dynamic
|
|
2870
|
+
* call whose callee expression yields a nodeset of NON-text nodes
|
|
2871
|
+
* ("node()()" — every node matches) crashed evaluate_operator: the
|
|
2872
|
+
* dyn-call fetch blind-cast nodes[0] to XPathTextNode* and read its
|
|
2873
|
+
* content field, which for an element/attribute node is a different
|
|
2874
|
+
* union — strncmp then dereferenced a wild pointer. A callee that is
|
|
2875
|
+
* not a text node is simply not a function reference: the call must
|
|
2876
|
+
* refuse (NULL), like every other non-carrier shape. */
|
|
2877
|
+
TEST(XPathDynCall, NonTextCalleeRefusesWithoutCrash) {
|
|
2878
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2879
|
+
LeptrisDocument doc =
|
|
2880
|
+
leptris_parse_string("<r><a/></r>", 11, &st);
|
|
2881
|
+
ASSERT_NE(doc, nullptr);
|
|
2882
|
+
LeptrisElement root = leptris_document_root(doc);
|
|
2883
|
+
ASSERT_NE(root, nullptr);
|
|
2884
|
+
|
|
2885
|
+
/* The first node() is an element — the blind-cast shape. */
|
|
2886
|
+
LeptrisXPathResult r =
|
|
2887
|
+
leptris_xpath_eval(doc, root, "node()()");
|
|
2888
|
+
leptris_xpath_result_free(r); /* NULL or empty, never a crash */
|
|
2889
|
+
|
|
2890
|
+
/* Attribute-led variant: the first node is an attribute node. */
|
|
2891
|
+
LeptrisXPathResult r2 =
|
|
2892
|
+
leptris_xpath_eval(doc, root, "r/@*");
|
|
2893
|
+
ASSERT_NE(r2, nullptr);
|
|
2894
|
+
leptris_xpath_result_free(r2);
|
|
2895
|
+
|
|
2896
|
+
leptris_document_free(doc);
|
|
2897
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
|
3
3
|
"name": "leptris",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.426",
|
|
5
5
|
"description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
|
|
6
6
|
"homepage": "https://github.com/leptris/leptris",
|
|
7
7
|
"license": "MIT",
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: leptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.426.1
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -69,6 +69,7 @@ files:
|
|
|
69
69
|
- LICENSE.md
|
|
70
70
|
- README.adoc
|
|
71
71
|
- Rakefile
|
|
72
|
+
- SUPPORTED_MINORS
|
|
72
73
|
- TODO.final/04-native-bundle-codesign-artifact-sync.md
|
|
73
74
|
- TODO.perf/01-ext-accelerated-default-reads.md
|
|
74
75
|
- TODO.perf/02-auto-enable-native-layer.md
|
|
@@ -170,7 +171,11 @@ files:
|
|
|
170
171
|
- lib/leptris/xml/iterparse.rb
|
|
171
172
|
- lib/leptris/xml/namespace.rb
|
|
172
173
|
- lib/leptris/xml/native.so
|
|
174
|
+
- lib/leptris/xml/native_3_1.so
|
|
175
|
+
- lib/leptris/xml/native_3_2.so
|
|
173
176
|
- lib/leptris/xml/native_3_3.so
|
|
177
|
+
- lib/leptris/xml/native_3_4.so
|
|
178
|
+
- lib/leptris/xml/native_4_0.so
|
|
174
179
|
- lib/leptris/xml/native_layer.rb
|
|
175
180
|
- lib/leptris/xml/node.rb
|
|
176
181
|
- lib/leptris/xml/node_set.rb
|
|
@@ -853,9 +858,52 @@ files:
|
|
|
853
858
|
- vendor-src/libleptris/test/fixtures/malformed.xml
|
|
854
859
|
- vendor-src/libleptris/test/fixtures/namespaces.xml
|
|
855
860
|
- vendor-src/libleptris/test/fixtures/utf16_decl.xml
|
|
861
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0000.xsl
|
|
862
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0001.xsl
|
|
863
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0002.xsl
|
|
864
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0003.xsl
|
|
865
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0004.xsl
|
|
866
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0005.xsl
|
|
867
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0006.xsl
|
|
868
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0007.xsl
|
|
869
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0008.xsl
|
|
870
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0009.xsl
|
|
871
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0010.xsl
|
|
872
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0011.xsl
|
|
873
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0012.xsl
|
|
874
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0013.xsl
|
|
875
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0014.xsl
|
|
876
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0015.xsl
|
|
877
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0016.xsl
|
|
878
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0017.xsl
|
|
879
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0018.xsl
|
|
880
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0019.xsl
|
|
881
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0020.xsl
|
|
882
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0021.xsl
|
|
883
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0022.xsl
|
|
884
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0023.xsl
|
|
885
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0024.xsl
|
|
886
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0025.xsl
|
|
887
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0026.xsl
|
|
888
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0027.xsl
|
|
889
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0028.xsl
|
|
890
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0029.xsl
|
|
891
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0030.xsl
|
|
892
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0031.xsl
|
|
893
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0032.xsl
|
|
894
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0033.xsl
|
|
895
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0034.xsl
|
|
896
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0035.xsl
|
|
897
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0036.xsl
|
|
898
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0037.xsl
|
|
899
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0038.xsl
|
|
900
|
+
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0039.xsl
|
|
856
901
|
- vendor-src/libleptris/test/fuzz/corpus/html_foreign_cdata_short_opener.bin
|
|
857
902
|
- vendor-src/libleptris/test/fuzz/corpus/seed1
|
|
858
903
|
- vendor-src/libleptris/test/fuzz/corpus/seed2
|
|
904
|
+
- vendor-src/libleptris/test/fuzz/corpus/xslt_astcache_uaf_fold.bin
|
|
905
|
+
- vendor-src/libleptris/test/fuzz/corpus/xslt_astcache_uaf_nightly.bin
|
|
906
|
+
- vendor-src/libleptris/test/fuzz/corpus/xslt_dyncall_nontext_callee_segv.xml
|
|
859
907
|
- vendor-src/libleptris/test/fuzz/corpus/xslt_empty_match_template_leak.xml
|
|
860
908
|
- vendor-src/libleptris/test/fuzz/corpus/xslt_union_number_head_segv.xml
|
|
861
909
|
- vendor-src/libleptris/test/fuzz/fuzz_html.c
|
|
@@ -863,6 +911,7 @@ files:
|
|
|
863
911
|
- vendor-src/libleptris/test/fuzz/fuzz_parse.c
|
|
864
912
|
- vendor-src/libleptris/test/fuzz/fuzz_xpath.c
|
|
865
913
|
- vendor-src/libleptris/test/fuzz/fuzz_xslt.c
|
|
914
|
+
- vendor-src/libleptris/test/fuzz/generators/gen_xslt_seeds.py
|
|
866
915
|
- vendor-src/libleptris/test/html/html5lib-redlist.txt
|
|
867
916
|
- vendor-src/libleptris/test/html/html5lib-tests/LICENSE
|
|
868
917
|
- vendor-src/libleptris/test/html/html5lib-tests/README.md
|