leptris 1.9.426.1-arm-linux → 1.9.428.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/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +41 -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 +284 -40
- 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/xpath/vm.c +18 -9
- data/vendor-src/libleptris/src/leptris/xpath/xpath_compiled.c +13 -1
- 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/src/leptris/xslt/xslt_parse.c +20 -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/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_astcache_uaf_session.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_carrier_number_uaf.bin +1 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_dispatch_union_dup_hbo.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_mixed_set_dispose_uaf.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/xslt_uaf_predicate_layer.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xml_seeds.py +132 -0
- data/vendor-src/libleptris/test/rng/test_rng.cpp +297 -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 -1
|
@@ -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) {
|
|
@@ -241,7 +241,12 @@ XPathNodeSet* xpath_map_items_over(XPathContext* ctx, XPathNodeSet* ns,
|
|
|
241
241
|
XPathASTNode* expr) {
|
|
242
242
|
XPathNodeSet* out = xpath_nodeset_new();
|
|
243
243
|
if (!out) return NULL;
|
|
244
|
-
|
|
244
|
+
/* The owns flags assert facts about EVERY member of the kind —
|
|
245
|
+
* this loop appends raw document nodes (the nodeset branch), so
|
|
246
|
+
* the text flag moves to the synth-append branch below. An
|
|
247
|
+
* eager flag over mixed members made apply_predicates' dispose
|
|
248
|
+
* free document-owned text nodes (SOTA C1, nightly
|
|
249
|
+
* 44085294402). */
|
|
245
250
|
size_t n = ns ? ns->count : 0;
|
|
246
251
|
struct leptris_element* saved_node = ctx->context_node;
|
|
247
252
|
size_t saved_pos = ctx->context_position;
|
|
@@ -281,7 +286,10 @@ XPathNodeSet* xpath_map_items_over(XPathContext* ctx, XPathNodeSet* ns,
|
|
|
281
286
|
XPathTextNode* tn =
|
|
282
287
|
synth_text(piece ? piece : "", piece ? strlen(piece) : 0);
|
|
283
288
|
free(piece);
|
|
284
|
-
if (tn)
|
|
289
|
+
if (tn) {
|
|
290
|
+
xpath_nodeset_add(out, tn);
|
|
291
|
+
out->owns_synthetic_text = 1;
|
|
292
|
+
}
|
|
285
293
|
}
|
|
286
294
|
xpath_result_free(item);
|
|
287
295
|
}
|
|
@@ -1003,6 +1011,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1003
1011
|
return NULL;
|
|
1004
1012
|
}
|
|
1005
1013
|
out->owns_synthetic_text = 1;
|
|
1014
|
+
/* Safe despite the raw element adds below: only TEXT/ATTR/NS
|
|
1015
|
+
* members are ever disposed and every non-element member here
|
|
1016
|
+
* is synth-wrapped — the raw members are exclusively ELEMENT
|
|
1017
|
+
* nodes. */
|
|
1006
1018
|
out->is_sequence = 1;
|
|
1007
1019
|
|
|
1008
1020
|
XPathNodeSet* ns =
|
|
@@ -1100,6 +1112,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1100
1112
|
XPathNodeSet* one = xpath_nodeset_new();
|
|
1101
1113
|
if (!one) break;
|
|
1102
1114
|
if (ns) {
|
|
1115
|
+
/* Document node: the var set owns nothing (the
|
|
1116
|
+
* ownership flag asserts a fact about every member —
|
|
1117
|
+
* a lie here made the unbind dispose a document
|
|
1118
|
+
* node, SOTA C1 nightly 44085294402). */
|
|
1103
1119
|
xpath_nodeset_add(one, ns->nodes[i]);
|
|
1104
1120
|
} else {
|
|
1105
1121
|
char* sv = xpath_to_string(domain);
|
|
@@ -1114,17 +1130,21 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1114
1130
|
XPathTextNode* tn =
|
|
1115
1131
|
synth_text(marked, sl + 2);
|
|
1116
1132
|
free(marked);
|
|
1117
|
-
if (tn)
|
|
1133
|
+
if (tn) {
|
|
1134
|
+
xpath_nodeset_add(one, tn);
|
|
1135
|
+
one->owns_synthetic_text = 1;
|
|
1136
|
+
}
|
|
1118
1137
|
}
|
|
1119
1138
|
free(sv);
|
|
1120
1139
|
} else {
|
|
1121
1140
|
XPathTextNode* tn =
|
|
1122
1141
|
synth_text(sv ? sv : "", sv ? strlen(sv) : 0);
|
|
1123
1142
|
free(sv);
|
|
1124
|
-
if (tn)
|
|
1143
|
+
if (tn) {
|
|
1144
|
+
xpath_nodeset_add(one, tn);
|
|
1145
|
+
one->owns_synthetic_text = 1;
|
|
1146
|
+
}
|
|
1125
1147
|
}
|
|
1126
|
-
/* synth members above are var-owned */
|
|
1127
|
-
one->owns_synthetic_text = 1;
|
|
1128
1148
|
}
|
|
1129
1149
|
xpath_variable_set_nodeset(var, one);
|
|
1130
1150
|
if (pos_var) {
|
|
@@ -1900,9 +1920,12 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1900
1920
|
pname[pn] = 0;
|
|
1901
1921
|
XPathNodeSet* one = xpath_nodeset_new();
|
|
1902
1922
|
if (one) {
|
|
1903
|
-
/* set_remove frees the nodeset
|
|
1904
|
-
* the
|
|
1905
|
-
|
|
1923
|
+
/* set_remove frees the nodeset: the flag rides ONLY
|
|
1924
|
+
* the synth-append branches — carrier-node members
|
|
1925
|
+
* are document references and must never dispose
|
|
1926
|
+
* (a whole-set flag over mixed members freed a
|
|
1927
|
+
* document text node in the nightly, SOTA C1
|
|
1928
|
+
* 44085294402). */
|
|
1906
1929
|
if (ai < (size_t)ast->child_count) {
|
|
1907
1930
|
struct leptris_xpath_result* ar =
|
|
1908
1931
|
evaluate_expr(ctx, ast->children[ai]);
|
|
@@ -1928,7 +1951,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1928
1951
|
} else {
|
|
1929
1952
|
XPathTextNode* tn = synth_text(
|
|
1930
1953
|
mem[j], strlen(mem[j]));
|
|
1931
|
-
if (tn)
|
|
1954
|
+
if (tn) {
|
|
1955
|
+
xpath_nodeset_add(one, tn);
|
|
1956
|
+
one->owns_synthetic_text = 1;
|
|
1957
|
+
}
|
|
1932
1958
|
}
|
|
1933
1959
|
free(mem[j]);
|
|
1934
1960
|
}
|
|
@@ -1947,7 +1973,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1947
1973
|
synth_text(sv ? sv : "",
|
|
1948
1974
|
sv ? strlen(sv) : 0);
|
|
1949
1975
|
free(sv);
|
|
1950
|
-
if (tn)
|
|
1976
|
+
if (tn) {
|
|
1977
|
+
xpath_nodeset_add(one, tn);
|
|
1978
|
+
one->owns_synthetic_text = 1;
|
|
1979
|
+
}
|
|
1951
1980
|
sv = NULL;
|
|
1952
1981
|
}
|
|
1953
1982
|
if (sv) free(sv);
|
|
@@ -2090,26 +2119,39 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
2090
2119
|
}
|
|
2091
2120
|
XPathNodeSet* one = xpath_nodeset_new();
|
|
2092
2121
|
if (one) {
|
|
2093
|
-
one->owns_synthetic_text = 1;
|
|
2094
2122
|
if (v->type == XPATH_RESULT_NODESET &&
|
|
2095
2123
|
v->value.nodeset_value &&
|
|
2096
2124
|
v->value.nodeset_value->count > 0) {
|
|
2097
2125
|
/* Node operands bind AS NODES — the arm
|
|
2098
2126
|
* body steps axes on them
|
|
2099
2127
|
* (fold-left-016: $a/text()); a
|
|
2100
|
-
* string-value synth has no children.
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2128
|
+
* string-value synth has no children.
|
|
2129
|
+
* Members v OWNS transfer here (v is
|
|
2130
|
+
* freed below; the transfer keeps `one`
|
|
2131
|
+
* the sole owner). Document members ride
|
|
2132
|
+
* with no flag — a whole-set flag over
|
|
2133
|
+
* mixed members made the case-arm dispose
|
|
2134
|
+
* a document text node (SOTA C1, nightly
|
|
2135
|
+
* 44085294402). */
|
|
2136
|
+
XPathNodeSet* bv = v->value.nodeset_value;
|
|
2137
|
+
for (size_t xi = 0; xi < bv->count; xi++)
|
|
2138
|
+
xpath_nodeset_add(one, bv->nodes[xi]);
|
|
2139
|
+
one->owns_attributes |= bv->owns_attributes;
|
|
2140
|
+
one->owns_namespaces |= bv->owns_namespaces;
|
|
2141
|
+
one->owns_synthetic_text |=
|
|
2142
|
+
bv->owns_synthetic_text;
|
|
2143
|
+
bv->owns_attributes = 0;
|
|
2144
|
+
bv->owns_namespaces = 0;
|
|
2145
|
+
bv->owns_synthetic_text = 0;
|
|
2107
2146
|
} else {
|
|
2108
2147
|
const char* bindv =
|
|
2109
2148
|
marked ? marked : (vs_ ? vs_ : "");
|
|
2110
2149
|
XPathTextNode* tn = xpath_synth_text(
|
|
2111
2150
|
bindv, strlen(bindv));
|
|
2112
|
-
if (tn)
|
|
2151
|
+
if (tn) {
|
|
2152
|
+
xpath_nodeset_add(one, tn);
|
|
2153
|
+
one->owns_synthetic_text = 1;
|
|
2154
|
+
}
|
|
2113
2155
|
}
|
|
2114
2156
|
XPathVariable* var = xpath_variable_set_add(
|
|
2115
2157
|
vs, vn, XPATH_VAR_TYPE_NODE_SET);
|
|
@@ -3578,7 +3620,6 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
3578
3620
|
if (op == XPATH_OP_SEQUENCE) {
|
|
3579
3621
|
XPathNodeSet* out = xpath_nodeset_new();
|
|
3580
3622
|
if (!out) return NULL;
|
|
3581
|
-
out->owns_synthetic_text = 1;
|
|
3582
3623
|
out->is_sequence = 1;
|
|
3583
3624
|
for (size_t i = 0; i < ast->child_count; i++) {
|
|
3584
3625
|
struct leptris_xpath_result* item =
|
|
@@ -3587,6 +3628,11 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
3587
3628
|
if (item->type == XPATH_RESULT_NODESET &&
|
|
3588
3629
|
item->value.nodeset_value) {
|
|
3589
3630
|
XPathNodeSet* is = item->value.nodeset_value;
|
|
3631
|
+
/* The sequence flag asserts a fact about every
|
|
3632
|
+
* member: raw document members ride in with NO flag
|
|
3633
|
+
* (an eager flag here let apply_predicates dispose
|
|
3634
|
+
* document-owned text nodes — SOTA C1, nightly
|
|
3635
|
+
* 44085294402); owned members transfer below. */
|
|
3590
3636
|
for (size_t j = 0; j < is->count; j++)
|
|
3591
3637
|
xpath_nodeset_add(out, is->nodes[j]);
|
|
3592
3638
|
/* #720: an item nodeset may OWN synthetic nodes
|
|
@@ -3643,7 +3689,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
3643
3689
|
marked[2 + pl] = 0;
|
|
3644
3690
|
XPathTextNode* tn = synth_text(marked, pl + 2);
|
|
3645
3691
|
free(marked);
|
|
3646
|
-
if (tn)
|
|
3692
|
+
if (tn) {
|
|
3693
|
+
xpath_nodeset_add(out, tn);
|
|
3694
|
+
out->owns_synthetic_text = 1;
|
|
3695
|
+
}
|
|
3647
3696
|
}
|
|
3648
3697
|
} else if (item->type == XPATH_RESULT_BOOLEAN) {
|
|
3649
3698
|
/* "\x03B" marks boolean members so EBV
|
|
@@ -3659,7 +3708,10 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
3659
3708
|
XPathTextNode* tn =
|
|
3660
3709
|
synth_text(marked, strlen(bp) + 2);
|
|
3661
3710
|
free(marked);
|
|
3662
|
-
if (tn)
|
|
3711
|
+
if (tn) {
|
|
3712
|
+
xpath_nodeset_add(out, tn);
|
|
3713
|
+
out->owns_synthetic_text = 1;
|
|
3714
|
+
}
|
|
3663
3715
|
}
|
|
3664
3716
|
} else {
|
|
3665
3717
|
char fam = (item->type == XPATH_RESULT_STRING &&
|
|
@@ -3678,13 +3730,19 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
3678
3730
|
XPathTextNode* tn =
|
|
3679
3731
|
synth_text(marked, pl + 2);
|
|
3680
3732
|
free(marked);
|
|
3681
|
-
if (tn)
|
|
3733
|
+
if (tn) {
|
|
3734
|
+
xpath_nodeset_add(out, tn);
|
|
3735
|
+
out->owns_synthetic_text = 1;
|
|
3736
|
+
}
|
|
3682
3737
|
}
|
|
3683
3738
|
} else {
|
|
3684
3739
|
XPathTextNode* tn =
|
|
3685
3740
|
synth_text(piece ? piece : "",
|
|
3686
3741
|
piece ? strlen(piece) : 0);
|
|
3687
|
-
if (tn)
|
|
3742
|
+
if (tn) {
|
|
3743
|
+
xpath_nodeset_add(out, tn);
|
|
3744
|
+
out->owns_synthetic_text = 1;
|
|
3745
|
+
}
|
|
3688
3746
|
}
|
|
3689
3747
|
}
|
|
3690
3748
|
free(piece);
|
|
@@ -507,6 +507,30 @@ static XPathASTNode* parse_expr(XPathParser* parser) {
|
|
|
507
507
|
XPathASTNode* xpath_parse(XPathParser* parser) {
|
|
508
508
|
if (!parser) return NULL;
|
|
509
509
|
|
|
510
|
+
/* Nesting fence: the parse chain recurses per '(' / '[' — a
|
|
511
|
+
* pathological expression dies on the C stack before any bound.
|
|
512
|
+
* The tokens are already lexed, so one O(n) scan measures the
|
|
513
|
+
* exact nesting depth and fails cleanly past the fence (SOTA C1,
|
|
514
|
+
* nightly 44278536885, crash-94a0fc23: '[[[[...' × thousands). */
|
|
515
|
+
{
|
|
516
|
+
int cur = 0, max = 0;
|
|
517
|
+
for (size_t i = 0; i < parser->token_count; i++) {
|
|
518
|
+
int t = parser->tokens[i].type;
|
|
519
|
+
if (t == TOK_LPAREN || t == TOK_LBRACKET) {
|
|
520
|
+
if (++cur > max) max = cur;
|
|
521
|
+
} else if (t == TOK_RPAREN || t == TOK_RBRACKET) {
|
|
522
|
+
if (cur > 0) cur--;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (max > 128) {
|
|
526
|
+
snprintf(parser->error_msg, sizeof(parser->error_msg),
|
|
527
|
+
"expression nesting too deep (%d levels)", max);
|
|
528
|
+
leptris_set_error(LEPTRIS_ERROR_XPATH_SYNTAX,
|
|
529
|
+
parser->error_msg);
|
|
530
|
+
return NULL;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
510
534
|
XPathASTNode* ast = parse_expr(parser);
|
|
511
535
|
/* XPath 3.1 top-level sequence: Expr ::= ExprSingle ("," ExprSingle)*.
|
|
512
536
|
* One member parses as itself; a comma list builds the sequence
|
|
@@ -1622,18 +1622,27 @@ static int vm_apply_binary_op(XPathVM* vm, XPathContext* ctx,
|
|
|
1622
1622
|
|
|
1623
1623
|
/* Issue #514: transfer synthetic-node ownership from
|
|
1624
1624
|
* the operands — see the twin fix in
|
|
1625
|
-
* evaluator_operators.c.
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1625
|
+
* evaluator_operators.c. PER SIDE (finding 8): the
|
|
1626
|
+
* concat above runs on one leg when the other is
|
|
1627
|
+
* empty (rn/ln NULL), and gating the transfer on
|
|
1628
|
+
* `ln && rn` left the result sharing an owned node
|
|
1629
|
+
* the owning operand still freed at cleanup — the
|
|
1630
|
+
* pushed result handed out disposed memory. */
|
|
1631
|
+
result->value.nodeset_value->owns_attributes =
|
|
1632
|
+
(ln ? ln->owns_attributes : 0) ||
|
|
1633
|
+
(rn ? rn->owns_attributes : 0);
|
|
1634
|
+
result->value.nodeset_value->owns_namespaces =
|
|
1635
|
+
(ln ? ln->owns_namespaces : 0) ||
|
|
1636
|
+
(rn ? rn->owns_namespaces : 0);
|
|
1637
|
+
result->value.nodeset_value->owns_synthetic_text =
|
|
1638
|
+
(ln ? ln->owns_synthetic_text : 0) ||
|
|
1639
|
+
(rn ? rn->owns_synthetic_text : 0);
|
|
1640
|
+
if (ln) {
|
|
1634
1641
|
ln->owns_attributes = 0;
|
|
1635
1642
|
ln->owns_namespaces = 0;
|
|
1636
1643
|
ln->owns_synthetic_text = 0;
|
|
1644
|
+
}
|
|
1645
|
+
if (rn) {
|
|
1637
1646
|
rn->owns_attributes = 0;
|
|
1638
1647
|
rn->owns_namespaces = 0;
|
|
1639
1648
|
rn->owns_synthetic_text = 0;
|
|
@@ -77,7 +77,19 @@ static struct leptris_xpath_result* compiled_eval_bc_pinned(
|
|
|
77
77
|
&ce);
|
|
78
78
|
LeptrisXPathBytecode* bc = hit ? ce.bc : NULL;
|
|
79
79
|
if (hit && !bc) {
|
|
80
|
-
|
|
80
|
+
/* Finding 6, the last edge: compile from THE SLOT'S graph
|
|
81
|
+
* (ce.ast), never from compiled->ast. Same expression text
|
|
82
|
+
* can have DIFFERENT parses in different records: this
|
|
83
|
+
* compiled handle may hold the graveyard's graph (its insert
|
|
84
|
+
* pinned a pre-eviction parse) while the live slot holds a
|
|
85
|
+
* fresher parse of the same text. Bytecode compiled from
|
|
86
|
+
* compiled->ast but STORED into the slot paired its constants
|
|
87
|
+
* with a graph the slot does not own — the slot's later
|
|
88
|
+
* holders ran bytecode whose constants pointed into a graph
|
|
89
|
+
* only the old handle kept alive, and the handle's teardown
|
|
90
|
+
* freed that graph under them (the nightly's UAF at
|
|
91
|
+
* evaluate_function_call_impl). */
|
|
92
|
+
bc = leptris_xpath_compile_ast(ce.ast);
|
|
81
93
|
if (bc) {
|
|
82
94
|
xpath_ast_cache_store_bc(compiled->expr,
|
|
83
95
|
compiled->expr_len, bc);
|
|
@@ -3420,6 +3420,21 @@ static int xslt_bind_param_defaults(XsltExec* ex, const XsltInstr* body,
|
|
|
3420
3420
|
static int xslt_invoke_template(XsltExec* ex, const XsltTemplate* t,
|
|
3421
3421
|
LeptrisElement node,
|
|
3422
3422
|
const XsltInstr* with_params) {
|
|
3423
|
+
/* Recursion fence (SOTA C1, nightly 44278536885): an identity
|
|
3424
|
+
* template whose apply-templates select re-selects the same node
|
|
3425
|
+
* recurses until the OS stack dies. The fence fails the
|
|
3426
|
+
* transform cleanly instead. 100 sits far below the C stack even
|
|
3427
|
+
* under ASan's frame inflation (~60KB/level measured on the
|
|
3428
|
+
* nightly input) while covering every legitimate rule chain —
|
|
3429
|
+
* libxslt dies on the OS stack for the same input. */
|
|
3430
|
+
if (++ex->apply_depth > 100) {
|
|
3431
|
+
snprintf(ex->error, sizeof(ex->error),
|
|
3432
|
+
"template recursion exceeded 100 levels "
|
|
3433
|
+
"(apply-templates/call-template loop)");
|
|
3434
|
+
ex->eval_error = 1;
|
|
3435
|
+
ex->apply_depth--;
|
|
3436
|
+
return -2;
|
|
3437
|
+
}
|
|
3423
3438
|
const XsltTemplate* saved_t = ex->current_template;
|
|
3424
3439
|
ex->current_template = t;
|
|
3425
3440
|
/* §11: with-param expressions evaluate in the CALLER's scope;
|
|
@@ -3480,6 +3495,7 @@ static int xslt_invoke_template(XsltExec* ex, const XsltTemplate* t,
|
|
|
3480
3495
|
ex->current_template = saved_t;
|
|
3481
3496
|
xslt_pop_vars_to(ex, mark);
|
|
3482
3497
|
ex->vars = caller;
|
|
3498
|
+
ex->apply_depth--;
|
|
3483
3499
|
return rc;
|
|
3484
3500
|
}
|
|
3485
3501
|
|
|
@@ -662,6 +662,12 @@ typedef struct xslt_exec {
|
|
|
662
662
|
* resolves candidates against THIS rule's import rank). */
|
|
663
663
|
const XsltTemplate* current_template;
|
|
664
664
|
|
|
665
|
+
/* Recursion fence (SOTA C1, nightly 44278536885): template
|
|
666
|
+
* invocations in flight. apply-templates select="." identity
|
|
667
|
+
* loops recurse unbounded and die on the C stack — the engine
|
|
668
|
+
* fails the transform cleanly past the fence instead. */
|
|
669
|
+
int apply_depth;
|
|
670
|
+
|
|
665
671
|
/* §4: the in-scope ns bindings of the instruction in flight —
|
|
666
672
|
* installed by the walker, consumed by xslt_eval. */
|
|
667
673
|
LeptrisXPathNsSet current_ns;
|
|
@@ -2012,6 +2012,15 @@ void xslt_sheet_build_dispatch(XsltStylesheet* sheet) {
|
|
|
2012
2012
|
n * sizeof(XsltTemplate*));
|
|
2013
2013
|
if (!k2->list) continue;
|
|
2014
2014
|
}
|
|
2015
|
+
/* Finding 7, the value-index twin: same
|
|
2016
|
+
* dedupe (a template can carry two identical
|
|
2017
|
+
* [@k='v'] alternatives). */
|
|
2018
|
+
{
|
|
2019
|
+
int dup = 0;
|
|
2020
|
+
for (size_t i = 0; i < k2->n && !dup; i++)
|
|
2021
|
+
dup = (k2->list[i] == t);
|
|
2022
|
+
if (dup) continue;
|
|
2023
|
+
}
|
|
2015
2024
|
k2->list[k2->n++] = t;
|
|
2016
2025
|
continue;
|
|
2017
2026
|
}
|
|
@@ -2042,6 +2051,17 @@ void xslt_sheet_build_dispatch(XsltStylesheet* sheet) {
|
|
|
2042
2051
|
n * sizeof(XsltTemplate*));
|
|
2043
2052
|
if (!k->list) continue;
|
|
2044
2053
|
}
|
|
2054
|
+
/* Finding 7 (the fuzzer's "a|…|t|…|t" unions): a
|
|
2055
|
+
* template can name the same leaf in SEVERAL
|
|
2056
|
+
* alternatives, and every append grew k->n past
|
|
2057
|
+
* the n-sized list. A template also must not be
|
|
2058
|
+
* dispatched twice per node — dedupe per key. */
|
|
2059
|
+
{
|
|
2060
|
+
int dup = 0;
|
|
2061
|
+
for (size_t i = 0; i < k->n && !dup; i++)
|
|
2062
|
+
dup = (k->list[i] == t);
|
|
2063
|
+
if (dup) continue;
|
|
2064
|
+
}
|
|
2045
2065
|
k->list[k->n++] = t;
|
|
2046
2066
|
}
|
|
2047
2067
|
if (has_other) {
|
|
@@ -98,3 +98,12 @@ Add the file to `corpus/`, then add its name + XPath to the `DOCS` /
|
|
|
98
98
|
`XPATHS` tables in **all three** runners (order matters: fixed corpus
|
|
99
99
|
order, no sorting), re-run all three, and update the verified-output
|
|
100
100
|
block above plus this README's tables.
|
|
101
|
+
|
|
102
|
+
## Where the pins come from
|
|
103
|
+
|
|
104
|
+
The gate reads its four binding pins from the LATEST RELEASE's
|
|
105
|
+
`build-manifest.json` (`bindings` section — recorded live from the
|
|
106
|
+
registries by the release workflow, Gate C3). Releases predating
|
|
107
|
+
schema/2 fall back to the hardcoded `FALLBACK_*` train in the
|
|
108
|
+
workflow header; the diffpins branches only need to touch those
|
|
109
|
+
fallbacks, never the install steps.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xmlstylesheet ymlversion="1.0"><xsl:template mat<xslch=":s
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<xsl:stylesheet xion="1.0"><xsl:template match="/"><xsl:for-each select="item/r[@mode]-[lmerge-acast()]|6'deapply-templatund(nude(mr@ib))"/></xsl:template></xsl:stylesheet>
|
|
Binary file
|