teptris 0.3.0.2 → 0.3.4.1
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/ext/teptris_ext/engine/README.md +1 -1
- data/ext/teptris_ext/engine/src/include/teptris/plan.h +4 -0
- data/ext/teptris_ext/engine/src/include/teptris/version.h +1 -1
- data/ext/teptris_ext/engine/src/teptris/dom/dom.c +8 -4
- data/ext/teptris_ext/engine/src/teptris/plan/plan.c +39 -0
- data/lib/teptris/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63a08d9be8387bccda44fa806c55a762dfd2be0f84d5a1f832c1a9dfea018d67
|
|
4
|
+
data.tar.gz: c52a5a07c65f99e678d43844efba63f8b50c592837a32217683282cffa8f822d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4330fd1cfb9016e174306525fe25f3ce5bbc40661a742a66ececebf591d5783831b0bdfd053d64c289d73aa0ad424d2eeaf5e315553ae72bb4dabe21a2200a1
|
|
7
|
+
data.tar.gz: 26cb5d188688905fc062b43fd02a1f73d5c1951c6afc4eaee1052da75abdfcd66c5e1597a4022466d2859e01f8f2348387d935ed4303e9787e116e666dc4250f
|
|
@@ -11,6 +11,10 @@ extern "C" {
|
|
|
11
11
|
|
|
12
12
|
#define TEPTRIS_PLAN_ABI_VERSION 1
|
|
13
13
|
|
|
14
|
+
/* walk_table recurses per NESTED level; plans deeper than this are
|
|
15
|
+
* rejected at build (the parser and builder share the 512 ceiling). */
|
|
16
|
+
#define TEPTRIS_PLAN_MAX_DEPTH 512
|
|
17
|
+
|
|
14
18
|
typedef struct teptris_plan teptris_plan;
|
|
15
19
|
typedef struct teptris_plan_result teptris_plan_result;
|
|
16
20
|
|
|
@@ -146,8 +146,10 @@ teptris_status teptris_dom_table_insert_slot(teptris_document *doc,
|
|
|
146
146
|
if (ne == NULL) {
|
|
147
147
|
return TEPTRIS_ERR_ALLOC;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
if (t->as.table.len > 0) {
|
|
150
|
+
memcpy(ne, t->as.table.entries,
|
|
151
|
+
t->as.table.len * sizeof(teptris_entry));
|
|
152
|
+
}
|
|
151
153
|
t->as.table.entries = ne;
|
|
152
154
|
}
|
|
153
155
|
t->as.table.cap = ncap;
|
|
@@ -181,8 +183,10 @@ teptris_status teptris_dom_array_push(teptris_document *doc, teptris_node *a,
|
|
|
181
183
|
if (ni == NULL) {
|
|
182
184
|
return TEPTRIS_ERR_ALLOC;
|
|
183
185
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
if (a->as.array.len > 0) {
|
|
187
|
+
memcpy(ni, a->as.array.items,
|
|
188
|
+
a->as.array.len * sizeof(teptris_node *));
|
|
189
|
+
}
|
|
186
190
|
a->as.array.items = ni;
|
|
187
191
|
}
|
|
188
192
|
a->as.array.cap = ncap;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include <string.h>
|
|
8
8
|
|
|
9
9
|
#include "teptris/dom/dom.h"
|
|
10
|
+
#include <stdio.h>
|
|
10
11
|
#include "teptris/plan.h"
|
|
11
12
|
|
|
12
13
|
typedef struct plan_row {
|
|
@@ -86,6 +87,44 @@ teptris_plan *teptris_plan_build(const teptris_plan_spec *spec,
|
|
|
86
87
|
p->rows[i].kind = r->kind;
|
|
87
88
|
p->rows[i].sub = r->sub;
|
|
88
89
|
}
|
|
90
|
+
/* Depth gate (rows are validated above: sub < plan_count). BFS
|
|
91
|
+
* from the root relaxes depths in one ascending pass — sub-plans
|
|
92
|
+
* always lay out after their parent. walk_table recurses per
|
|
93
|
+
* NESTED level, so an unbounded hostile plan would crash the
|
|
94
|
+
* host's stack; the parser and builder share the 512 ceiling. */
|
|
95
|
+
/* entries, not bytes — the byte-sized malloc here is the same
|
|
96
|
+
* overflow the ruby plan_build hit (documented there) */
|
|
97
|
+
uint32_t *depths = malloc(p->plan_count * sizeof(*depths));
|
|
98
|
+
if (depths == NULL) {
|
|
99
|
+
teptris_plan_free(p);
|
|
100
|
+
*status = TEPTRIS_ERR_ALLOC;
|
|
101
|
+
return NULL;
|
|
102
|
+
}
|
|
103
|
+
memset(depths, 0, p->plan_count * sizeof(*depths));
|
|
104
|
+
for (uint32_t pi = 0; pi < p->plan_count; pi++) {
|
|
105
|
+
uint32_t lo = p->first_row[pi];
|
|
106
|
+
uint32_t hi = p->first_row[pi + 1];
|
|
107
|
+
for (uint32_t ri = lo; ri < hi; ri++) {
|
|
108
|
+
if (p->rows[ri].kind == TEPTRIS_PLAN_NESTED) {
|
|
109
|
+
uint32_t sub = p->rows[ri].sub;
|
|
110
|
+
if (depths[sub] <= depths[pi] + 1) {
|
|
111
|
+
depths[sub] = depths[pi] + 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
int too_deep = 0;
|
|
117
|
+
for (uint32_t pi = 0; pi < p->plan_count; pi++) {
|
|
118
|
+
if (depths[pi] > TEPTRIS_PLAN_MAX_DEPTH) {
|
|
119
|
+
too_deep = 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
free(depths);
|
|
123
|
+
if (too_deep) {
|
|
124
|
+
teptris_plan_free(p);
|
|
125
|
+
*status = TEPTRIS_ERR_ARG;
|
|
126
|
+
return NULL;
|
|
127
|
+
}
|
|
89
128
|
*status = TEPTRIS_OK;
|
|
90
129
|
return p;
|
|
91
130
|
}
|
data/lib/teptris/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: teptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- teptris contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A native C extension over libteptris, a C99 TOML 1.1 parser/emitter.
|
|
14
14
|
API shape mirrors the tomlib gem.
|