Skip to content

DeltaByteArrayDecoder panics on invalid prefix lengths #9796

@pchintar

Description

@pchintar

Problem

DeltaByteArrayDecoder::get assumes decoded prefix lengths are always valid and directly slices:

self.previous_value[0..prefix_len]

If the decoded prefix_len is negative (after decoding) or larger than
previous_value.len(), this results in a slice bounds panic.

Expected Behavior

The decoder should return Err on invalid input instead of panicking.

Actual Behavior

Invalid prefix lengths can cause a panic such as:

range end index X out of range for slice of length Y

Reproduction

This can be reproduced by:

  • encoding valid DELTA_BYTE_ARRAY data
  • modifying the prefix-length stream (DELTA_BINARY_PACKED)
  • decoding using DeltaByteArrayDecoder::get

This leads to a panic instead of returning an error.

Notes

  • There is currently no validation for:
    • negative prefix lengths
    • prefix lengths exceeding previous_value.len()
  • Other decoders (e.g., DELTA_BINARY_PACKED) perform validation on decoded values,
    but this check is missing here.

Impact

This can cause unexpected panics when reading invalid or unexpected encoded data,
instead of returning a controlled error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions