Skip to content

hardening(index_block): validate shared prefix against restart-key span #186

@polaz

Description

@polaz

Context

Found during review of #182.

Problem

parse_truncated in src/table/index_block/block_handle.rs validates shared_prefix_len only against the current entry boundary (prefix_end <= offset). For restart intervals with multiple truncated entries, this can still allow a shared prefix that extends beyond the restart key bytes.

Suggested approach

  • carry restart-key span (start + len) into truncated parse path
  • reject shared_prefix_len > restart_key_len before constructing SliceIndexes
  • add corruption regression test for malformed shared_prefix_len

Files involved

  • src/table/index_block/block_handle.rs
  • src/table/block/decoder.rs
  • parser tests in src/table/index_block/block_handle.rs

Estimate

4h (implementation 2.5h, tests 1h, review/cleanup 0.5h)

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCode defect, incorrect behavior, crash, data corruptiontestTests, test infrastructure, test helpers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions