Commit 84d109e
repr: Fix panic decoding an Avro decimal with empty unscaled bytes
twos_complement_be_to_numeric_inner read input[0] without first checking
that the slice is non-empty, panicking with "index out of bounds: the len
is 0 but the index is 0" on an empty byte string.
That input is reachable from the wire: an Avro `decimal` logical type whose
unscaled value is encoded as zero-length `bytes` flows straight from a Kafka
message body through AvroFlatDecoder into this function, so a single crafted
(or buggy-producer) message crashes Avro source decoding — an availability
bug for ingestion. Our own encoder never emits an empty byte string (zero is
the single byte 0x00), and Java's Avro decoder likewise rejects empty input
(BigInteger throws "Zero length BigInteger"), so the right behaviour is a
clean decode error, not a silent zero. The caller already maps the Err to a
DecodeError, so the malformed row now surfaces as a decode error instead of
aborting the worker.
Found by the new avro_decode_fuzzed_schema fuzz target.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0455a96 commit 84d109e
1 file changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
402 | 410 | | |
403 | 411 | | |
404 | 412 | | |
| |||
469 | 477 | | |
470 | 478 | | |
471 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
472 | 495 | | |
473 | 496 | | |
474 | 497 | | |
| |||
0 commit comments