Commit a70b1e2
fix: harden vortex.zoned metadata parsing against malformed input; decimal sum fallback (#197)
The aggregate-spec zone-map decoder added in #197 (commit 9e20edc) had two
post-merge review findings.
Overflow class: ProtoCursor guarded reads with `pos + len > bound`. A varint
length up to Long.MAX_VALUE overflows `pos + len` to negative, so the `> bound`
check is false and the guard passes — then `new byte[(int) len]` throws
NegativeArraySizeException, or `pos` advances negative and the next segment read
throws IndexOutOfBoundsException. This is untrusted file metadata (ADR 0003), so
it must never surface a raw JDK exception. Every length/offset check
(readAggregateSpecId message descent, readString, advance/skipField) is rewritten
overflow-safe: the invariant pos <= bound holds throughout, so `bound - pos >= 0`
never overflows and the guard becomes `len < 0 || len > bound - pos`. Malformed
metadata now falls back to per-chunk stats.
Decimal divergence: Rust's default_zoned_aggregate_fns (vortex-layout
zoned/writer.rs) emits a `sum` column whenever Sum.return_dtype is Some — which is
Some(Decimal(precision + 10)) for a Decimal column (sum/mod.rs) — while our
sumDtype returns null for Decimal. Dropping that field with `continue` reconstructs
{max,min,null_count} for an encoded {max,min,sum,null_count} table, so the
positional decode reads null_count out of the sum buffer. The reconstructor now
distinguishes "Rust also omits this" (nan_count over non-float per nan_count/mod.rs,
min/max over an unsupported column per min_max minmax_supported_dtype — safe skip)
from "Rust keeps a field we cannot map" (decimal sum, bounded_max/min nested state
— return null so the whole column falls back to correct-but-unpruned per-chunk
stats).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 02ce276 commit a70b1e2
4 files changed
Lines changed: 196 additions & 26 deletions
File tree
- docs
- reader/src
- main/java/io/github/dfa1/vortex/reader/layout
- test/java/io/github/dfa1/vortex/reader/layout
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
| 225 | + | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
Lines changed: 58 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
177 | 188 | | |
178 | 189 | | |
179 | 190 | | |
180 | 191 | | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
184 | 223 | | |
185 | 224 | | |
186 | 225 | | |
| |||
400 | 439 | | |
401 | 440 | | |
402 | 441 | | |
403 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
404 | 446 | | |
405 | 447 | | |
406 | 448 | | |
| |||
426 | 468 | | |
427 | 469 | | |
428 | 470 | | |
429 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
430 | 476 | | |
431 | 477 | | |
432 | 478 | | |
| |||
436 | 482 | | |
437 | 483 | | |
438 | 484 | | |
439 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
440 | 489 | | |
441 | 490 | | |
442 | 491 | | |
| |||
0 commit comments