leptris 1.9.427.0-arm-linux → 1.9.429.0-arm-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 +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/native_3_3.so +0 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +28 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/scripts/verify_manifest.py +11 -3
- data/vendor-src/libleptris/src/leptris/encoding/wrapper.c +13 -3
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +19 -0
- data/vendor-src/libleptris/src/leptris/rng/parse.c +21 -5
- data/vendor-src/libleptris/src/leptris/rng/validate.c +136 -44
- data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +59 -19
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +83 -25
- data/vendor-src/libleptris/src/leptris/xpath/parser.c +24 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_exec.c +16 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_internal.h +6 -0
- data/vendor-src/libleptris/test/differential/README.md +9 -0
- data/vendor-src/libleptris/test/differential/package.json +1 -1
- data/vendor-src/libleptris/test/differential/rs-runner/Cargo.toml +1 -1
- data/vendor-src/libleptris/test/fuzz/corpus/encoding_decl_strstr_hbo.bin +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/html_tree_amplification_timeout.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xpath_bracket_nesting_stack_overflow.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_apply_identity_recursion.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_mixed_set_dispose_uaf.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_html_seeds.py +101 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xml_seeds.py +132 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xpath_seeds.py +123 -0
- data/vendor-src/libleptris/test/rng/test_rng.cpp +165 -0
- data/vendor-src/libleptris/test/xpath/test_xpath.cpp +77 -0
- data/vendor-src/libleptris/test/xpath/test_xslt.cpp +80 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64d3b1f6cd2aed9a2c3f474ab09c8b46d35d8087338bc9a1621e38c0de8dde34
|
|
4
|
+
data.tar.gz: f63fba8e03f5133bb157d764b5c6a74fc3ab003cac57c2236914a796af63dcac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a737c07acefb5d523fd3fd1a4c03cb8b30c3fb0b3fc2bd17d5f85007958006ce108d2f8713233a3dd705de4d59616b519a992c46771094e606e49e25f5a412a1
|
|
7
|
+
data.tar.gz: 6753fc1aa54fd860e5904e6eed3cbabb654800fe9c1a481704e7624214956e61c8fdfbce5bfa42e9a4ac42b516b6e55edb48e926d061f4797494704acbc51661
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ 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.429"
|
|
12
12
|
|
|
13
13
|
# THE SSOT for the per-minor native bundle list (ruby#645): one line,
|
|
14
14
|
# space-separated, consumed by the Rakefile, the per-minor builder's
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/native.so
CHANGED
|
Binary file
|
|
Binary file
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.429] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **RELAX NG regression (1.9.428.0)**: `combine="interleave"` merges no longer interleaved the added pattern INTO a base sequence — the added element could not sit between two base elements (RELAX NG §4.17; ruby#650). The interleave walk is now a per-branch cursor machine with full backtracking (branches match non-contiguously; repeatable members hold their cursor and may match again after another branch consumes; the search returns the furthest completion with a step budget for pathological documents). Within-a-body order still holds, per Jing. leptris#2094.
|
|
8
|
+
- Fuzz tooling: gen_xpath_seeds emits per-file corpus entries (the nightly's XPath leg takes corpus directories).
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## [1.9.428] - 2026-11-18
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- RELAX NG: a `combine="choice"`/`combine="interleave"` merge wraps each merged body in an implicit group (Jing §4.10) — the branch is the body's whole sibling chain, not its first element. Multi-element bodies under a combined define no longer reject everything after the first element (the openmath3.rng OMBIND shape — OM3 documents rejected OMBVAR/OMA after the head OMS) (leptris#2088, leptris#2089).
|
|
17
|
+
|
|
18
|
+
### Memory safety (SOTA C1, fuzz-lane findings 8–11)
|
|
19
|
+
|
|
20
|
+
- XPath synthetic nodes (attribute/namespace/text) are shared by value across nodesets, sequences, and variable bindings; no set owns them exclusively. Disposing one no longer frees the struct under its other holders: the node parks (a defined-dead sentinel + thread-local graveyard drained at cleanup) instead (nightly 44085294402).
|
|
21
|
+
- Five binding producers (simple-map, sequence, for loop-var, HOF params, switch cases) flagged result sets eagerly and appended raw document nodes — a predicate drop then disposed a document-owned text node. Ownership flags now assert facts and transfer with owned members (leptris#2083).
|
|
22
|
+
- The encoding-declaration scan is bounded: the buffer is not NUL-terminated on every caller and the unbounded `strstr` read past the end.
|
|
23
|
+
- Two clean-error recursion fences: template application caps at 100 levels (an `apply-templates select="."` identity loop previously died on the OS stack), and the XPath parser rejects bracket nesting past 128 with a syntax error instead of exhausting the C stack (nightly 44278536885).
|
|
24
|
+
|
|
25
|
+
### Packaging
|
|
26
|
+
|
|
27
|
+
- Every release now carries `build-manifest.json` (per-platform toolchain identities, artifact hashes, and the binding versions riding the release), generated by the release workflow; the byte-identity smoke is green after pinning the compiler's path-derived symbol seed; the differential gate reads its pins from the release manifest (leptris#2085, leptris#2086).
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
3
31
|
## [1.9.427] - 2026-11-18
|
|
4
32
|
|
|
5
33
|
### Fixed
|
|
@@ -25,13 +25,21 @@ matched a local file byte-for-byte; 1 = at least one artifact is missing
|
|
|
25
25
|
or mismatched. A local file with no manifest entry is a warning, not a
|
|
26
26
|
failure (extra build outputs are allowed).
|
|
27
27
|
|
|
28
|
-
Manifest schema ("leptris.build-manifest/
|
|
28
|
+
Manifest schema ("leptris.build-manifest/2", as produced by
|
|
29
29
|
.github/workflows/build-manifests.yml):
|
|
30
30
|
|
|
31
31
|
{
|
|
32
|
-
"schema": "leptris.build-manifest/
|
|
32
|
+
"schema": "leptris.build-manifest/2",
|
|
33
33
|
"tag": "v1.9.367", // release tag built
|
|
34
34
|
"generated_at_utc": "2026-10-21T00:00:00Z",
|
|
35
|
+
"bindings": { // schema/2 (A6/C3): the
|
|
36
|
+
"rubygems": "1.9.427.0", // published binding
|
|
37
|
+
"pypi": "1.9.427.0", // versions riding this
|
|
38
|
+
"npm": "0.1.62", // engine release, live
|
|
39
|
+
"crates_io": "1.9.0", // from the registries;
|
|
40
|
+
// differential.yml reads
|
|
41
|
+
// these as its pins
|
|
42
|
+
},
|
|
35
43
|
"platforms": {
|
|
36
44
|
"<platform>": { // key: matrix leg name, e.g. linux-amd64
|
|
37
45
|
"leg": "native", // native | amalgamated
|
|
@@ -63,7 +71,7 @@ ARTIFACT_RE = re.compile(
|
|
|
63
71
|
r"^(libleptris\.(a|dll|lib)|libleptris\.so(\.[0-9.]+)?"
|
|
64
72
|
r"|libleptris\.[0-9.]+\.dylib|leptris\.(lib|dll))$")
|
|
65
73
|
|
|
66
|
-
SCHEMA = "leptris.build-manifest/
|
|
74
|
+
SCHEMA = "leptris.build-manifest/2"
|
|
67
75
|
|
|
68
76
|
|
|
69
77
|
def sha256_of(path):
|
|
@@ -36,9 +36,19 @@ char* leptris_encoding_parse_declaration(const char* xml, size_t len) {
|
|
|
36
36
|
return NULL;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/* Find encoding=
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/* Find encoding= — BOUNDED: the buffer is NOT NUL-terminated on
|
|
40
|
+
* every caller (the fuzz harness passes exact-size buffers; the
|
|
41
|
+
* unbounded strstr read past the end — SOTA C1 finding 9,
|
|
42
|
+
* fx-art-crash-653f55991b38). */
|
|
43
|
+
const char* limit = xml + len;
|
|
44
|
+
const char* encoding_start = NULL;
|
|
45
|
+
for (const char* p = xml; p + 8 <= limit; p++) {
|
|
46
|
+
if (memcmp(p, "encoding", 8) == 0) {
|
|
47
|
+
encoding_start = p;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!encoding_start) {
|
|
42
52
|
return NULL;
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -551,6 +551,20 @@ typedef struct xpath_text_node {
|
|
|
551
551
|
struct leptris_element* owner; /* Parent element */
|
|
552
552
|
} XPathTextNode;
|
|
553
553
|
|
|
554
|
+
/* Disposed-synthetic parking (SOTA C1, nightly 44085294402): the
|
|
555
|
+
* XPath-side heap nodes (LeptrisAttributeNode / LeptrisNamespaceNode
|
|
556
|
+
* / XPathTextNode) are SHARED by value across nodesets, sequences and
|
|
557
|
+
* variable bindings — no single set owns them exclusively, so a
|
|
558
|
+
* dispose by one holder must not free the struct (or its payload)
|
|
559
|
+
* out from under the others. xpath_nodeset_dispose_node therefore
|
|
560
|
+
* PARKS: the type byte moves to the sentinel below and the struct
|
|
561
|
+
* joins a thread-local graveyard (drained by
|
|
562
|
+
* leptris_xpath_drain_thread_caches at thread exit). Late readers see
|
|
563
|
+
* a defined dead node and defined-dead content instead of freed
|
|
564
|
+
* memory — the same contract as the XPATH_RESULT_CACHED result
|
|
565
|
+
* parking. */
|
|
566
|
+
#define LEPTRIS_NODE_XPATH_PARKED ((LeptrisNodeType)127)
|
|
567
|
+
|
|
554
568
|
/* XPath node union - type-safe wrapper for all XPath node types */
|
|
555
569
|
typedef union xpath_node {
|
|
556
570
|
LeptrisNodeType type; /* First field for type checking */
|
|
@@ -673,6 +687,11 @@ typedef struct xpath_parser {
|
|
|
673
687
|
size_t token_count;
|
|
674
688
|
size_t token_pos;
|
|
675
689
|
char error_msg[256];
|
|
690
|
+
int depth; /* Expression nesting fence — the
|
|
691
|
+
* parse_* chain recurses per '(' '['
|
|
692
|
+
* '!' and dies on the C stack past
|
|
693
|
+
* the fence (SOTA C1, nightly
|
|
694
|
+
* 44278536885 family). */
|
|
676
695
|
} XPathParser;
|
|
677
696
|
|
|
678
697
|
/* XPath nodeset - Holds typed node pointers (elements or attributes).
|
|
@@ -363,10 +363,20 @@ static int add_define(RngGrammar* g, char* name, char* combine,
|
|
|
363
363
|
RngPattern* wrap =
|
|
364
364
|
pat_new(strcmp(d->combine, "interleave") == 0 ? RNG_INTERLEAVE
|
|
365
365
|
: RNG_CHOICE);
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
/* Each merged body is an IMPLICIT GROUP (Jing §4.10): the branch
|
|
367
|
+
* is the body's whole sibling chain, not its first element. A
|
|
368
|
+
* bare chain inside the combinator made the validator treat the
|
|
369
|
+
* body's 2nd..nth elements as further alternatives of the
|
|
370
|
+
* choice — <a/><b/> consumed a as the entire first branch and
|
|
371
|
+
* stranded b (openmath3 OMBIND, #2088). */
|
|
372
|
+
RngPattern* left = pat_new(RNG_GROUP);
|
|
373
|
+
pat_append(left, d->body);
|
|
374
|
+
RngPattern* right = pat_new(RNG_GROUP);
|
|
375
|
+
pat_append(right, body->first_child);
|
|
368
376
|
body->first_child = NULL;
|
|
369
377
|
rng_pattern_free(body);
|
|
378
|
+
pat_append(wrap, left);
|
|
379
|
+
pat_append(wrap, right);
|
|
370
380
|
rng_flatten_combinator(wrap);
|
|
371
381
|
d->body = wrap;
|
|
372
382
|
return 1;
|
|
@@ -511,15 +521,21 @@ static int handle_include(RngGrammar* g, LeptrisElement inc,
|
|
|
511
521
|
/* The WRAPPER stays as the define's body — same shape
|
|
512
522
|
* add_define produces — the combinator node is what
|
|
513
523
|
* the validator walks; unwrapping leaves bare
|
|
514
|
-
* siblings with no interleave/choice between them.
|
|
524
|
+
* siblings with no interleave/choice between them.
|
|
525
|
+
* Each branch wraps in GROUP (#2088, Jing §4.10): the
|
|
526
|
+
* branch is the body's whole sibling chain. */
|
|
515
527
|
RngPattern* wrap =
|
|
516
528
|
pat_new(strcmp(ncombine, "interleave") == 0
|
|
517
529
|
? RNG_INTERLEAVE
|
|
518
530
|
: RNG_CHOICE);
|
|
519
|
-
|
|
520
|
-
pat_append(
|
|
531
|
+
RngPattern* left = pat_new(RNG_GROUP);
|
|
532
|
+
pat_append(left, d->body);
|
|
533
|
+
RngPattern* right = pat_new(RNG_GROUP);
|
|
534
|
+
pat_append(right, body->first_child);
|
|
521
535
|
body->first_child = NULL;
|
|
522
536
|
rng_pattern_free(body);
|
|
537
|
+
pat_append(wrap, left);
|
|
538
|
+
pat_append(wrap, right);
|
|
523
539
|
rng_flatten_combinator(wrap);
|
|
524
540
|
free(d->combine);
|
|
525
541
|
d->combine = ncombine;
|
|
@@ -602,6 +602,119 @@ static size_t fold_list(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
|
602
602
|
static size_t match_seq(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
603
603
|
size_t n, size_t idx);
|
|
604
604
|
|
|
605
|
+
/* The interleave matcher (ruby#650): branches match NON-contiguously
|
|
606
|
+
* — that is what interleaving IS — so a window matcher is wrong (a
|
|
607
|
+
* group(base) branch fails atomically at the frontier even though its
|
|
608
|
+
* second element matches two positions later, after another branch
|
|
609
|
+
* consumes there). Each branch carries a CURSOR into its own child
|
|
610
|
+
* chain; the search advances one branch's head pattern at the shared
|
|
611
|
+
* frontier, recurses, and backtracks on overall failure. Jing does
|
|
612
|
+
* the same search over its interleave automaton. */
|
|
613
|
+
typedef struct {
|
|
614
|
+
RngPattern* cur[64]; /* the branch's remaining member pattern */
|
|
615
|
+
int unit[64]; /* the branch is a single non-group pattern */
|
|
616
|
+
int done[64]; /* the branch fully matched */
|
|
617
|
+
size_t cn;
|
|
618
|
+
unsigned long steps; /* search budget: invalid documents explode
|
|
619
|
+
combinatorially under full enumeration;
|
|
620
|
+
past the budget the match fails
|
|
621
|
+
conservatively (the diagnose pass then
|
|
622
|
+
reports the shortfall) */
|
|
623
|
+
} IlvState;
|
|
624
|
+
|
|
625
|
+
static size_t rng_interleave_try(RngVal* v, IlvState* st,
|
|
626
|
+
LeptrisNodeRef* kids, size_t n,
|
|
627
|
+
size_t i, unsigned held_mask);
|
|
628
|
+
|
|
629
|
+
/* Advance (or hold) branch b after its head matched r. A REPEATABLE
|
|
630
|
+
* member that CONSUMED stays on its cursor — it may match again after
|
|
631
|
+
* another branch consumes at the frontier (ruby#650: ics on both
|
|
632
|
+
* sides of the merged-in element). */
|
|
633
|
+
static void ilv_advance(IlvState* st, size_t b, RngPattern* h,
|
|
634
|
+
size_t r, size_t i) {
|
|
635
|
+
int repeatable = (h->kind == RNG_ZERO_OR_MORE ||
|
|
636
|
+
h->kind == RNG_ONE_OR_MORE);
|
|
637
|
+
if (st->unit[b]) {
|
|
638
|
+
if (repeatable && r > i) return; /* hold the cursor */
|
|
639
|
+
st->done[b] = 1;
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
if (repeatable && r > i) return; /* hold the cursor */
|
|
643
|
+
st->cur[b] = h->next;
|
|
644
|
+
st->done[b] = (h->next == NULL);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
static size_t rng_interleave_try(RngVal* v, IlvState* st,
|
|
648
|
+
LeptrisNodeRef* kids, size_t n,
|
|
649
|
+
size_t i, unsigned held_mask) {
|
|
650
|
+
size_t b;
|
|
651
|
+
for (b = 0; b < st->cn; b++) {
|
|
652
|
+
if (!st->done[b]) break;
|
|
653
|
+
}
|
|
654
|
+
if (b == st->cn) return i; /* every branch exhausted */
|
|
655
|
+
if (++st->steps > 200000) return (size_t)-1;
|
|
656
|
+
/* The search returns the FURTHEST completion, not the first: a
|
|
657
|
+
* branch finishing early can complete at a position that strands
|
|
658
|
+
* a repeatable member's later match (ruby#650 case 4: out=4 vs
|
|
659
|
+
* the required n=5). */
|
|
660
|
+
size_t best = (size_t)-1;
|
|
661
|
+
for (b = 0; b < st->cn; b++) {
|
|
662
|
+
if (st->done[b]) continue;
|
|
663
|
+
RngPattern* h = st->cur[b];
|
|
664
|
+
int repeatable = (h->kind == RNG_ZERO_OR_MORE ||
|
|
665
|
+
h->kind == RNG_ONE_OR_MORE);
|
|
666
|
+
size_t r = match_seq(v, h, kids, n, i);
|
|
667
|
+
if (r != (size_t)-1 && r > i) {
|
|
668
|
+
/* consuming: advance-or-hold, recurse at the new frontier
|
|
669
|
+
* — the frontier moved, so every hold is forgettable */
|
|
670
|
+
RngPattern* save = st->cur[b];
|
|
671
|
+
int save_done = st->done[b];
|
|
672
|
+
ilv_advance(st, b, h, r, i);
|
|
673
|
+
size_t out = rng_interleave_try(v, st, kids, n, r, 0);
|
|
674
|
+
st->cur[b] = save; /* backtrack */
|
|
675
|
+
st->done[b] = save_done;
|
|
676
|
+
if (out != (size_t)-1 && (best == (size_t)-1 || out > best))
|
|
677
|
+
best = out;
|
|
678
|
+
if (best == n) break; /* complete — cannot beat */
|
|
679
|
+
v->failed = 0;
|
|
680
|
+
v->err[0] = 0;
|
|
681
|
+
}
|
|
682
|
+
if (r != (size_t)-1 && r == i) {
|
|
683
|
+
if (repeatable && !(held_mask & (1u << b))) {
|
|
684
|
+
/* zero-width: the member may still feed at a LATER
|
|
685
|
+
* position — hold it and let the others move first
|
|
686
|
+
* (the mask guards the same-branch same-frontier
|
|
687
|
+
* ping-pong: each branch holds at most once per
|
|
688
|
+
* frontier) */
|
|
689
|
+
size_t out = rng_interleave_try(v, st, kids, n, i,
|
|
690
|
+
held_mask | (1u << b));
|
|
691
|
+
if (out != (size_t)-1 && (best == (size_t)-1 ||
|
|
692
|
+
out > best))
|
|
693
|
+
best = out;
|
|
694
|
+
if (best == n) break;
|
|
695
|
+
}
|
|
696
|
+
/* or the branch finishes here */
|
|
697
|
+
RngPattern* save = st->cur[b];
|
|
698
|
+
int save_done = st->done[b];
|
|
699
|
+
st->done[b] = 1;
|
|
700
|
+
size_t out = rng_interleave_try(v, st, kids, n, r, -1);
|
|
701
|
+
st->cur[b] = save; /* backtrack */
|
|
702
|
+
st->done[b] = save_done;
|
|
703
|
+
if (out != (size_t)-1 && (best == (size_t)-1 || out > best))
|
|
704
|
+
best = out;
|
|
705
|
+
if (best == n) break;
|
|
706
|
+
v->failed = 0;
|
|
707
|
+
v->err[0] = 0;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (r == (size_t)-1) {
|
|
711
|
+
v->failed = 0; /* speculative: try the next branch */
|
|
712
|
+
v->err[0] = 0;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return best;
|
|
716
|
+
}
|
|
717
|
+
|
|
605
718
|
static int leaf_matches(RngVal* v, RngPattern* p, LeptrisNodeRef node) {
|
|
606
719
|
LeptrisElement e = (LeptrisElement)node;
|
|
607
720
|
switch (p->kind) {
|
|
@@ -663,55 +776,34 @@ static size_t match_seq(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
|
663
776
|
return i;
|
|
664
777
|
}
|
|
665
778
|
case RNG_INTERLEAVE: {
|
|
666
|
-
/* Any order; every branch must be satisfied.
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
for (RngPattern* c = p->first_child; c && cn < 64;
|
|
677
|
-
c = c->next)
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
for (size_t b = 0; b < cn; b++) {
|
|
685
|
-
if (used[b]) continue;
|
|
686
|
-
size_t r = match_seq(v, ch[b], kids, n, i);
|
|
687
|
-
if (r != (size_t)-1 && r > i) {
|
|
688
|
-
used[b] = 1;
|
|
689
|
-
i = r;
|
|
690
|
-
progressed = 1;
|
|
691
|
-
} else if (r != (size_t)-1) {
|
|
692
|
-
/* zero-width here: leave the branch unused so
|
|
693
|
-
* a later position can still feed it. */
|
|
694
|
-
v->failed = 0;
|
|
695
|
-
v->err[0] = 0;
|
|
696
|
-
} else {
|
|
697
|
-
v->failed = 0;
|
|
698
|
-
v->err[0] = 0;
|
|
699
|
-
}
|
|
779
|
+
/* Any order; every branch must be satisfied. The cursor
|
|
780
|
+
* machine above: branches match non-contiguously with
|
|
781
|
+
* full backtracking. The earlier fixpoint walk could not
|
|
782
|
+
* DEFER a branch — combine="interleave" merges wrap each
|
|
783
|
+
* body in a GROUP (#2089), and group(base) as one branch
|
|
784
|
+
* must be able to PAUSE mid-sequence while another branch
|
|
785
|
+
* consumes at the frontier (ruby#650: the added element
|
|
786
|
+
* may sit between any two base elements, §4.17). */
|
|
787
|
+
IlvState st;
|
|
788
|
+
memset(&st, 0, sizeof(st));
|
|
789
|
+
for (RngPattern* c = p->first_child; c && st.cn < 64;
|
|
790
|
+
c = c->next) {
|
|
791
|
+
if (c->kind == RNG_GROUP && c->first_child) {
|
|
792
|
+
st.cur[st.cn] = c->first_child;
|
|
793
|
+
st.unit[st.cn] = 0;
|
|
794
|
+
} else {
|
|
795
|
+
st.cur[st.cn] = c;
|
|
796
|
+
st.unit[st.cn] = 1;
|
|
700
797
|
}
|
|
798
|
+
st.done[st.cn] = 0;
|
|
799
|
+
st.cn++;
|
|
701
800
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
size_t r = match_seq(v, ch[b], kids, n, i);
|
|
705
|
-
if (r == (size_t)-1 || r != i) {
|
|
706
|
-
/* A branch that consumes here contradicts the
|
|
707
|
-
* fixpoint above — treat as unsatisfied. */
|
|
708
|
-
return (size_t)-1;
|
|
709
|
-
}
|
|
801
|
+
size_t out = rng_interleave_try(v, &st, kids, n, idx, 0);
|
|
802
|
+
if (out == (size_t)-1) {
|
|
710
803
|
v->failed = 0;
|
|
711
804
|
v->err[0] = 0;
|
|
712
|
-
used[b] = 1;
|
|
713
805
|
}
|
|
714
|
-
return
|
|
806
|
+
return out;
|
|
715
807
|
}
|
|
716
808
|
case RNG_OPTIONAL: {
|
|
717
809
|
/* ruby-adjacent leptris#2078: the XML form flattens a
|
|
@@ -509,6 +509,8 @@ static LEPTRIS_THREAD_LOCAL struct {
|
|
|
509
509
|
size_t nodeset_count;
|
|
510
510
|
struct leptris_xpath_result* result_head;
|
|
511
511
|
size_t result_count;
|
|
512
|
+
void* synth_parked_head;
|
|
513
|
+
size_t synth_parked_count;
|
|
512
514
|
} g_xpath_tls;
|
|
513
515
|
|
|
514
516
|
|
|
@@ -519,6 +521,15 @@ static LEPTRIS_THREAD_LOCAL struct {
|
|
|
519
521
|
* to the struct). */
|
|
520
522
|
#define XPATH_RESULT_FREE_LIST_CAP 32
|
|
521
523
|
|
|
524
|
+
/* One parked synthetic node: the node keeps its payload readable
|
|
525
|
+
* (defined-dead), the wrapper remembers the original kind for the
|
|
526
|
+
* drain. */
|
|
527
|
+
typedef struct ParkedSynth {
|
|
528
|
+
struct ParkedSynth* next;
|
|
529
|
+
void* node;
|
|
530
|
+
LeptrisNodeType kind;
|
|
531
|
+
} ParkedSynth;
|
|
532
|
+
|
|
522
533
|
XPathNodeSet* xpath_nodeset_new(void) {
|
|
523
534
|
return xpath_nodeset_new_with_capacity(XPATH_NODESET_INLINE_CAPACITY);
|
|
524
535
|
}
|
|
@@ -541,6 +552,31 @@ void leptris_xpath_drain_thread_caches(void) {
|
|
|
541
552
|
g_xpath_tls.result_head = next;
|
|
542
553
|
}
|
|
543
554
|
g_xpath_tls.result_count = 0;
|
|
555
|
+
/* The parked synthetic nodes (LEPTRIS_NODE_XPATH_PARKED): the
|
|
556
|
+
* thread is exiting — no consumer can still reach them. */
|
|
557
|
+
while (g_xpath_tls.synth_parked_head) {
|
|
558
|
+
ParkedSynth* p = (ParkedSynth*)g_xpath_tls.synth_parked_head;
|
|
559
|
+
g_xpath_tls.synth_parked_head = p->next;
|
|
560
|
+
if (p->kind == LEPTRIS_NODE_ATTRIBUTE) {
|
|
561
|
+
LeptrisAttributeNode* attr = (LeptrisAttributeNode*)p->node;
|
|
562
|
+
LEPTRIS_FREE(attr->name);
|
|
563
|
+
LEPTRIS_FREE(attr->value);
|
|
564
|
+
LEPTRIS_FREE(attr->namespace_uri);
|
|
565
|
+
LEPTRIS_FREE(attr);
|
|
566
|
+
} else if (p->kind == LEPTRIS_NODE_NAMESPACE) {
|
|
567
|
+
LeptrisNamespaceNode* ns = (LeptrisNamespaceNode*)p->node;
|
|
568
|
+
LEPTRIS_FREE(ns->prefix);
|
|
569
|
+
LEPTRIS_FREE(ns->uri);
|
|
570
|
+
LEPTRIS_FREE(ns);
|
|
571
|
+
} else {
|
|
572
|
+
XPathTextNode* t = (XPathTextNode*)p->node;
|
|
573
|
+
LEPTRIS_FREE(t->content);
|
|
574
|
+
LEPTRIS_FREE(t);
|
|
575
|
+
}
|
|
576
|
+
LEPTRIS_FREE(p);
|
|
577
|
+
g_xpath_tls.synth_parked_count--;
|
|
578
|
+
}
|
|
579
|
+
g_xpath_tls.synth_parked_count = 0;
|
|
544
580
|
}
|
|
545
581
|
|
|
546
582
|
XPathNodeSet* xpath_nodeset_new_with_capacity(size_t capacity) {
|
|
@@ -595,27 +631,31 @@ XPathNodeSet* xpath_nodeset_new_with_capacity(size_t capacity) {
|
|
|
595
631
|
}
|
|
596
632
|
|
|
597
633
|
/* Dispose ONE heap-owned synthetic node (attribute/namespace/text).
|
|
598
|
-
* Shared by xpath_nodeset_free and the in-place predicate filter
|
|
599
|
-
*
|
|
600
|
-
* (
|
|
634
|
+
* Shared by xpath_nodeset_free and the in-place predicate filter.
|
|
635
|
+
*
|
|
636
|
+
* SOTA C1 (nightly 44085294402): these nodes are SHARED by value
|
|
637
|
+
* across nodesets/sequences/bindings — no set owns them exclusively,
|
|
638
|
+
* and a dispose by one holder used to free the struct under the
|
|
639
|
+
* others (the filtered set dropped the node; the flag-losing alias
|
|
640
|
+
* still held it; the axis step read freed memory). The dispose now
|
|
641
|
+
* PARKS (LEPTRIS_NODE_XPATH_PARKED + the thread-local graveyard,
|
|
642
|
+
* drained at thread exit): repeat-dispose and any late read see a
|
|
643
|
+
* defined dead node instead of freed memory. */
|
|
601
644
|
void xpath_nodeset_dispose_node(void* node) {
|
|
602
645
|
if (!node) return;
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
if (t->content) LEPTRIS_FREE(t->content);
|
|
617
|
-
LEPTRIS_FREE(t);
|
|
618
|
-
}
|
|
646
|
+
int ty = (int)XPATH_NODE_TYPE(node);
|
|
647
|
+
if (ty == (int)LEPTRIS_NODE_XPATH_PARKED) return;
|
|
648
|
+
if (ty != LEPTRIS_NODE_ATTRIBUTE && ty != LEPTRIS_NODE_NAMESPACE &&
|
|
649
|
+
ty != LEPTRIS_NODE_TEXT)
|
|
650
|
+
return;
|
|
651
|
+
ParkedSynth* p = (ParkedSynth*)LEPTRIS_ALLOC(ParkedSynth);
|
|
652
|
+
if (!p) return; /* un-parked: the node stays alive, leak over UAF */
|
|
653
|
+
p->node = node;
|
|
654
|
+
p->kind = (LeptrisNodeType)ty;
|
|
655
|
+
p->next = (ParkedSynth*)g_xpath_tls.synth_parked_head;
|
|
656
|
+
g_xpath_tls.synth_parked_head = p;
|
|
657
|
+
g_xpath_tls.synth_parked_count++;
|
|
658
|
+
XPATH_NODE_TYPE(node) = LEPTRIS_NODE_XPATH_PARKED;
|
|
619
659
|
}
|
|
620
660
|
|
|
621
661
|
void xpath_nodeset_free(XPathNodeSet* nodeset) {
|