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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16869d7dc17dada9785490a4cc1268a02c36a4926a198b31f692021af453835a
4
- data.tar.gz: 53a738130ff1d160c40f6e40fef79d41d4920f5188372ba626a1bf5090a83d74
3
+ metadata.gz: 63a08d9be8387bccda44fa806c55a762dfd2be0f84d5a1f832c1a9dfea018d67
4
+ data.tar.gz: c52a5a07c65f99e678d43844efba63f8b50c592837a32217683282cffa8f822d
5
5
  SHA512:
6
- metadata.gz: 6c1fde58fa36cce4e57af73453ace01e0ddcb82c08f83d9e1d0be3d95038fe2046d5a686f539ab41f451cc7289c10d2376bf5b29452dd2208a877cbd85598cbf
7
- data.tar.gz: 45b1747790ff1a16b5d26f688c15b2dd3a9b31d2c9772af0a2f82564ee42548a5647a525383e768295e90fa4a13b6adc90be5701c69c88c253efad575f85094d
6
+ metadata.gz: d4330fd1cfb9016e174306525fe25f3ce5bbc40661a742a66ececebf591d5783831b0bdfd053d64c289d73aa0ad424d2eeaf5e315553ae72bb4dabe21a2200a1
7
+ data.tar.gz: 26cb5d188688905fc062b43fd02a1f73d5c1951c6afc4eaee1052da75abdfcd66c5e1597a4022466d2859e01f8f2348387d935ed4303e9787e116e666dc4250f
@@ -1,4 +1,4 @@
1
- # libteptris 0.3.0 — vendored source
1
+ # libteptris 0.3.4 — vendored source
2
2
 
3
3
  This directory carries the COMPLETE C source of the engine this
4
4
  gem's extension was built from (the packaging doctrine: compiled
@@ -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
 
@@ -4,6 +4,6 @@
4
4
  #define TEPTRIS_VERSION_MAJOR 0
5
5
  #define TEPTRIS_VERSION_MINOR 3
6
6
  #define TEPTRIS_VERSION_PATCH 0
7
- #define TEPTRIS_VERSION_STRING "0.3.0"
7
+ #define TEPTRIS_VERSION_STRING "0.3.4"
8
8
 
9
9
  #endif /* TEPTRIS_VERSION_H */
@@ -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
- memcpy(ne, t->as.table.entries,
150
- t->as.table.len * sizeof(teptris_entry));
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
- memcpy(ni, a->as.array.items,
185
- a->as.array.len * sizeof(teptris_node *));
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teptris
4
- VERSION = "0.3.0.2"
4
+ VERSION = "0.3.4.1"
5
5
  end
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.0.2
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-08 00:00:00.000000000 Z
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.