Skip to content

Example in find_chunk_edge() can panic 'range start index' #29

@allada

Description

@allada

Using some example code here:
https://docs.rs/hash-roll/0.3.0/hash_roll/trait.Chunk.html#tymethod.find_chunk_edge

It turns out that discard_ct could result in data.len() + 1 in size as seen in this code:
https://docs.rs/hash-roll/0.3.0/src/hash_roll/fastcdc.rs.html#75

The only happens when the boundary is on the last byte and can result in i equaling data.len() causing &data[..data.len() + 1] resulting in a panic.

The fix is simple, I might suggest adding something like this to the docs:

if discard_ct > data_buf.len() {
    break;
}

Thanks for the hard work in providing this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions