Commit febfcc1
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 9e20edc commit febfcc1
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 | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| 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 | | |
| |||
Lines changed: 136 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
297 | 314 | | |
298 | 315 | | |
299 | 316 | | |
| |||
303 | 320 | | |
304 | 321 | | |
305 | 322 | | |
306 | | - | |
| 323 | + | |
307 | 324 | | |
308 | 325 | | |
309 | | - | |
| 326 | + | |
310 | 327 | | |
311 | 328 | | |
312 | 329 | | |
313 | 330 | | |
314 | 331 | | |
315 | | - | |
| 332 | + | |
316 | 333 | | |
317 | 334 | | |
318 | | - | |
| 335 | + | |
319 | 336 | | |
320 | 337 | | |
321 | 338 | | |
| |||
324 | 341 | | |
325 | 342 | | |
326 | 343 | | |
327 | | - | |
| 344 | + | |
328 | 345 | | |
329 | 346 | | |
330 | | - | |
331 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
332 | 441 | | |
333 | 442 | | |
334 | 443 | | |
| |||
372 | 481 | | |
373 | 482 | | |
374 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
375 | 495 | | |
0 commit comments