leptris 1.9.388.0-ppc64le-linux → 1.9.389.0-ppc64le-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 238b6117d6d53b2e74db8530678f08b444e405ed9569cc0d5c794bc1539de2db
4
- data.tar.gz: 6e3a5e2de83a00123bc4ea19fd4818526809f05248b41e0aa6d7a9d9532d71a2
3
+ metadata.gz: e44ebccdfaf5bf4827e70bef39014db27495c9b8a75ec7021ef64b4c5071d821
4
+ data.tar.gz: 386db1cceadaa37208ed1f68e7e014ced0be911df07ea3813e3e0414a7fcbab4
5
5
  SHA512:
6
- metadata.gz: ae6c2a635dce0825ae7f0d85ecfaf343a912f551ce7a88e62f5686de2dbfa1ed736aa8c512a3c33ffa3ab236de554ff1ac7ecc316d419cda9bf2e7ec6c68db91
7
- data.tar.gz: d96b043f56180f0fc6c79a9a25c1678d1161d099b544ed0ba4ebfa5a220fec998b287b591d6535305d3a42b5bb7eada48576f0276ea930b4cfc5db4313589da5
6
+ metadata.gz: a883f44d891d1034c0c122827e687e581982b070838425a1760b55f32cccd5a3ca5ddf706b26e7e50c6b064d3d209cf8ebc4706cebb298b9795ca8d1ccaa75ce
7
+ data.tar.gz: eaf431976b58bca8f974a27b2fb0656dbe0ba328413be0bbadf2a6718580c09875bfd669d9431c0290ed200a096902c853c14445e9c28a37e3ab7ae8e4597e50
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### Changed — 1.9.389.0 (rides libleptris 1.9.389)
4
+
5
+ - Engine pin 1.9.388 -> 1.9.389: the XSD content-model automaton
6
+ size cap (leptris/leptris#1897, #1894 — pathological occurrence
7
+ products reject in microseconds via an analytic product bound,
8
+ with a 1e6 expansion cap backstop; over-cap models fail loudly
9
+ through the structured rows).
10
+
3
11
  ### Changed — 1.9.388.0 (rides libleptris 1.9.388)
4
12
 
5
13
  - Engine pin 1.9.386 -> 1.9.388: carries the one-pass text-run scan
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.388"
11
+ LIBLEPTRIS_VERSION = "1.9.389"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.388.0"
4
+ VERSION = "1.9.389.0"
5
5
  end
data/lib/libleptris.so CHANGED
Binary file
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.388
4
+ - libleptris v1.9.389
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,29 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.389] - 2026-10-29
4
+
5
+ ### Fixed
6
+
7
+ - **XSD: size-cap the content-model automaton (leptris#1897,
8
+ leptris#1894).** A counted particle multiplies the expanded NFA
9
+ (finite `maxOccurs` copies the subtree per copy), so nested large
10
+ bounds grew the automaton exponentially and a huge finite bound
11
+ walked the copy loop until the process died — jetsam/OOM with no
12
+ diagnostic, which read as a flaky harness in the W3C XML Schema
13
+ Test Suite batch runner. Two layers: an analytic, saturating
14
+ product bound computed BEFORE the build rejects pathological
15
+ models in microseconds (the 2000x2000 repro measured 10.0s ->
16
+ 0ms), and a 1e6 state/transition expansion cap as the backstop
17
+ for shapes the walk cannot see (cyclic groups). Over-cap models
18
+ fail LOUDLY: a `content-model` structured row on instance
19
+ validation and a `-1` (not evaluable) from the public
20
+ `leptris_xsd_content_valid` with the message on
21
+ `leptris_xsd_error`. The issue's own repro (seq maxOccurs=100 x
22
+ element unbounded) lowers to a ~200-state loop model and pins
23
+ green.
24
+
25
+
26
+
3
27
  ## [1.9.388] - 2026-10-29
4
28
 
5
29
  ### Fixed
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.388
6
+ VERSION 1.9.389
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -3651,8 +3651,17 @@ LEPTRIS_API int leptris_xsd_content_valid(
3651
3651
  XsdCm* model = ct->first_child;
3652
3652
  if (!model) return child_count == 0;
3653
3653
 
3654
- return xsd_content_valid(s, model, s->target_ns, child_names,
3655
- child_ns, child_count);
3654
+ int ok = xsd_content_valid(s, model, s->target_ns, child_names,
3655
+ child_ns, child_count);
3656
+ /* #1894: -2 = the model crosses the automaton size cap — surface
3657
+ * the loud structured row and keep the public contract's -1 for
3658
+ * "not evaluable". */
3659
+ if (ok == -2) {
3660
+ xsd_set_error(s, "content model exceeds the automaton size "
3661
+ "cap (pathological occurrence product)");
3662
+ return -1;
3663
+ }
3664
+ return ok;
3656
3665
  }
3657
3666
 
3658
3667
  LEPTRIS_API size_t leptris_xsd_declaration_count(LeptrisXsdSchema schema) {
@@ -29,12 +29,34 @@ typedef struct {
29
29
  int start, accept;
30
30
  struct leptris_xsd_schema* s; /* group-ref resolution */
31
31
  int depth; /* cyclic-group guard */
32
+ int overflow; /* #1894: crossed XSD_CM_NFA_MAX — abort the build */
32
33
  } CmNfa;
33
34
 
34
- static int nfa_state(CmNfa* n) { return n->state_count++; }
35
+ /* leptris#1894: a counted particle multiplies the expanded NFA (finite
36
+ * maxOccurs copies the subtree per copy), so nested large bounds grow
37
+ * the automaton exponentially and a huge finite bound walks the copy
38
+ * loop until the process dies (jetsam/OOM, no diagnostic). Crossing
39
+ * this bound aborts the build; xsd_content_valid reports -2 and the
40
+ * callers surface a loud structured row. Generous: legitimate suite
41
+ * content models stay orders of magnitude below it. */
42
+ #define XSD_CM_NFA_MAX 1000000
43
+
44
+ static int nfa_state(CmNfa* n) {
45
+ if (n->overflow) return 0;
46
+ if (n->state_count >= XSD_CM_NFA_MAX) {
47
+ n->overflow = 1;
48
+ return 0;
49
+ }
50
+ return n->state_count++;
51
+ }
35
52
 
36
53
  static void nfa_trans(CmNfa* n, int from, int symbol, XsdCm* particle,
37
54
  int to) {
55
+ if (n->overflow) return;
56
+ if (n->count >= XSD_CM_NFA_MAX) {
57
+ n->overflow = 1;
58
+ return;
59
+ }
38
60
  if (n->count == n->cap) {
39
61
  size_t cap = n->cap ? n->cap * 2 : 16;
40
62
  CmTrans* grown = (CmTrans*)realloc(n->trans, cap * sizeof(*grown));
@@ -125,7 +147,9 @@ static void cm_build(CmNfa* n, XsdCm* node, int from, int to) {
125
147
  /* occurrence bounds: min copies, then (max-min) optionals, or an
126
148
  * epsilon self-loop region for unbounded. */
127
149
  static void cm_build_occurrence(CmNfa* n, XsdCm* node, int from, int to) {
150
+ if (n->overflow) return;
128
151
  for (int i = 0; i < node->min; i++) {
152
+ if (n->overflow) return;
129
153
  int mid = nfa_state(n);
130
154
  cm_build(n, node, from, mid);
131
155
  from = mid;
@@ -138,6 +162,7 @@ static void cm_build_occurrence(CmNfa* n, XsdCm* node, int from, int to) {
138
162
  return;
139
163
  }
140
164
  for (int i = node->min; i < node->max; i++) {
165
+ if (n->overflow) return;
141
166
  nfa_trans(n, from, -1, NULL, to);
142
167
  int mid = nfa_state(n);
143
168
  cm_build(n, node, from, mid);
@@ -146,6 +171,62 @@ static void cm_build_occurrence(CmNfa* n, XsdCm* node, int from, int to) {
146
171
  nfa_trans(n, from, -1, NULL, to);
147
172
  }
148
173
 
174
+ /* ---- #1894 analytic product bound (pre-build rejection) ----------- */
175
+
176
+ /* Saturating upper bound on the states+transitions one subtree
177
+ * expands, honoring the same occurrence lowering cm_build_occurrence
178
+ * performs: finite max copies the subtree max times; unbounded lowers
179
+ * to ONE loop region (min + 1 copies). Groups follow like cm_build
180
+ * (depth-capped; unresolved/cyclic refs count as 1 — the expansion
181
+ * cap remains the backstop for anything the walk cannot see). Returns
182
+ * nonzero when the bound crosses XSD_CM_NFA_MAX. */
183
+ static int cm_bound_over(struct leptris_xsd_schema* s,
184
+ const XsdCm* node, size_t* bound, int depth) {
185
+ if (!node || depth > 64) return 0;
186
+ size_t sub;
187
+ switch (node->kind) {
188
+ case XSD_CM_ELEMENT:
189
+ case XSD_CM_ANY:
190
+ sub = 1;
191
+ break;
192
+ case XSD_CM_GROUP_REF: {
193
+ XsdGroupDef* g = s ? xsd_find_group(s, node->name) : NULL;
194
+ if (!g || !g->model ||
195
+ cm_bound_over(s, g->model, &sub, depth + 1))
196
+ sub = 1;
197
+ break;
198
+ }
199
+ case XSD_CM_SEQ:
200
+ case XSD_CM_ALL:
201
+ case XSD_CM_CHOICE: {
202
+ sub = 0;
203
+ for (const XsdCm* c = node->first_child; c; c = c->next) {
204
+ size_t cb = 0;
205
+ if (cm_bound_over(s, c, &cb, depth + 1)) return 1;
206
+ if (sub > XSD_CM_NFA_MAX) return 1;
207
+ sub += cb;
208
+ }
209
+ break;
210
+ }
211
+ default:
212
+ sub = 1;
213
+ break;
214
+ }
215
+ /* occurrence multiplier: copies of the subtree */
216
+ size_t copies;
217
+ if (node->max < 0)
218
+ copies = (size_t)(node->min > 0 ? node->min : 0) + 1;
219
+ else
220
+ copies = (size_t)(node->max > 0 ? node->max : 0);
221
+ if (copies == 0) {
222
+ *bound = 0;
223
+ return 0;
224
+ }
225
+ if (sub != 0 && copies > XSD_CM_NFA_MAX / sub) return 1;
226
+ *bound = sub * copies + 1;
227
+ return *bound > XSD_CM_NFA_MAX;
228
+ }
229
+
149
230
  /* ---- namespace filter (xs:any/@namespace) ------------------------ */
150
231
 
151
232
  /* XSD 1.1 notQName hit test (moxml#460): ##defined matches a name
@@ -297,7 +378,19 @@ int xsd_content_valid(struct leptris_xsd_schema* s, XsdCm* model,
297
378
  n.s = s;
298
379
  n.start = nfa_state(&n);
299
380
  n.accept = nfa_state(&n);
381
+ /* #1894: bound the expansion analytically BEFORE building — a
382
+ * pathological occurrence product (nested finite maxOccurs)
383
+ * rejects in microseconds instead of growing the automaton until
384
+ * the process dies. */
385
+ {
386
+ size_t bound = 0;
387
+ if (cm_bound_over(s, model, &bound, 0)) return -2;
388
+ }
300
389
  cm_build_occurrence(&n, model, n.start, n.accept);
390
+ if (n.overflow) {
391
+ free(n.trans);
392
+ return -2;
393
+ }
301
394
 
302
395
  StateSet live;
303
396
  memset(&live, 0, sizeof(live));
@@ -391,6 +391,19 @@ static void validate_children(struct xsd_validator* v,
391
391
  * min == 0. names/uris stay NULL (never dereferenced at n==0). */
392
392
  int ok = xsd_content_valid(s, model, xsd_target_ns(s), names, uris,
393
393
  n);
394
+ if (ok == -2) {
395
+ /* #1894: pathological occurrence product — the automaton
396
+ * exceeds the compile-time size cap. Loud, not a hang. */
397
+ const char* l2 = NULL;
398
+ leptris_element_expanded_name(elem, &l2, NULL, NULL);
399
+ verrf_atk(v, elem, "content-model", l2 ? l2 : "", "element",
400
+ l2 ? l2 : "",
401
+ "content model exceeds the automaton size cap "
402
+ "(pathological occurrence product)");
403
+ free(names);
404
+ free(uris);
405
+ return;
406
+ }
394
407
  if (ok) {
395
408
  free(names);
396
409
  free(uris);
@@ -3624,3 +3624,59 @@ TEST(XsdValidate, QNameNotationIgnoreLengthFacets) {
3624
3624
  EXPECT_EQ(validate_doc(ul, "<test a='x y'/>"), 1);
3625
3625
  EXPECT_EQ(validate_doc(ul, "<test a='x'/>"), 0);
3626
3626
  }
3627
+
3628
+ /* leptris#1894: pathological occurrence products. A counted particle
3629
+ * multiplies the expanded NFA (finite maxOccurs copies the subtree per
3630
+ * copy), so nested large bounds grow the automaton exponentially and a
3631
+ * huge finite bound walks the copy loop until the process dies. The
3632
+ * compile-time size guard fails LOUDLY — a structured report row and a
3633
+ * -1 (not evaluable) from the public face — instead of consuming the
3634
+ * machine. */
3635
+ TEST(XsdContent, PathologicalProductFailsLoudlyNotOom) {
3636
+ std::string xsd =
3637
+ "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
3638
+ "<xs:element name=\"r\"><xs:complexType><xs:sequence"
3639
+ " minOccurs=\"0\" maxOccurs=\"2000\"><xs:element name=\"e\""
3640
+ " minOccurs=\"0\" maxOccurs=\"2000\"/></xs:sequence>"
3641
+ "</xs:complexType></xs:element></xs:schema>";
3642
+ LeptrisStatus st = LEPTRIS_OK;
3643
+ LeptrisXsdSchema s =
3644
+ leptris_xsd_compile(xsd.data(), xsd.size(), &st);
3645
+ ASSERT_EQ(st, LEPTRIS_OK);
3646
+ ASSERT_NE(s, (LeptrisXsdSchema)0);
3647
+ /* 2000 x 2000 = 4e6 expanded copies — over the cap. Zero children
3648
+ * keep the simulation cheap; the BUILD is what the guard bounds. */
3649
+ EXPECT_EQ(leptris_xsd_content_valid(s, "r", NULL, NULL, 0), -1);
3650
+ /* the loud message rides the schema error face (validator rows
3651
+ * carry it on the instance-validation path instead) */
3652
+ const char* err = leptris_xsd_error(s);
3653
+ ASSERT_NE(err, nullptr);
3654
+ EXPECT_NE(std::string(err).find("size cap"), std::string::npos)
3655
+ << "error: " << err;
3656
+ leptris_xsd_free(s);
3657
+ }
3658
+
3659
+ TEST(XsdContent, Issue1894ReproStaysUnderCapAndCorrect) {
3660
+ /* The issue's exact shape — seq maxOccurs=100 x element
3661
+ * unbounded — lowers to a loop region (not copies) and must stay
3662
+ * far under the cap with normal answers. */
3663
+ const char xsd[] =
3664
+ "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
3665
+ "<xs:element name=\"r\"><xs:complexType><xs:sequence"
3666
+ " maxOccurs=\"100\"><xs:element name=\"e\""
3667
+ " maxOccurs=\"unbounded\"/></xs:sequence></xs:complexType>"
3668
+ "</xs:element></xs:schema>";
3669
+ LeptrisStatus st = LEPTRIS_OK;
3670
+ LeptrisXsdSchema s =
3671
+ leptris_xsd_compile(xsd, strlen(xsd), &st);
3672
+ ASSERT_EQ(st, LEPTRIS_OK);
3673
+ ASSERT_NE(s, (LeptrisXsdSchema)0);
3674
+ const char* e[] = {"e"};
3675
+ EXPECT_EQ(leptris_xsd_content_valid(s, "r", e, NULL, 1), 1);
3676
+ /* minOccurs defaults to 1 on the inner element: empty violates */
3677
+ EXPECT_EQ(leptris_xsd_content_valid(s, "r", NULL, NULL, 0), 0);
3678
+ const char* x[] = {"x"};
3679
+ EXPECT_EQ(leptris_xsd_content_valid(s, "r", x, NULL, 1), 0);
3680
+ EXPECT_EQ(leptris_xsd_error_count(s), 0u);
3681
+ leptris_xsd_free(s);
3682
+ }
@@ -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.388",
4
+ "version": "1.9.389",
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.388.0
4
+ version: 1.9.389.0
5
5
  platform: ppc64le-linux
6
6
  authors:
7
7
  - Ribose Inc.