Skip to content

fix(score): size chunk ptr buffers to PATH_MAX instead of 512 bytes#655

Merged
dmtrKovalenko merged 2 commits into
mainfrom
fix/resolve-ptrs-bounds
Jul 7, 2026
Merged

fix(score): size chunk ptr buffers to PATH_MAX instead of 512 bytes#655
dmtrKovalenko merged 2 commits into
mainfrom
fix/resolve-ptrs-bounds

Conversation

@dmtrKovalenko

@dmtrKovalenko dmtrKovalenko commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Proper fix for the OOB panic reported in #652.

The scoring hot path passed fixed [*const u8; 32] buffers (512 bytes) to resolve_ptrs while PATH_BUF_SIZE allows PATH_MAX-long paths (1024 on macOS, 4096 on Linux), so any path over 512 bytes panicked with an OOB index

elee7420-gif and others added 2 commits July 6, 2026 00:33
resolve_ptrs() iterates self.indices.len() times over a fixed-size
[*const u8; 32] buffer with no guard. When a file path exceeds 512
bytes (32 chunks × 16 bytes), the loop accesses buf[32] and panics:

    index out of bounds: the len is 32 but the index is 32

On macOS PATH_MAX is 1024, so any legitimately long path can trigger
this. Clamp count to buf.len() so pathological paths are truncated
gracefully instead of crashing.

Fixes an OOB panic found in pi-fff v0.9.6.
The scoring hot path passed fixed [*const u8; 32] buffers (32 * 16 =
512 bytes) to resolve_ptrs while PATH_BUF_SIZE allows PATH_MAX-long
paths (1024 on macOS, 4096 on Linux), so any path over 512 bytes
panicked with an out of bounds index.

neo_frizbee 0.10.4 makes the resolver buffer size a const generic, so
the buffers are now sized MAX_PATH_CHUNKS = PATH_BUF_SIZE / 16 at
compile time and long paths are matched in full instead of truncated.
Also covers the frizbee greedy fallback for haystacks longer than its
DP matrix which previously scanned a stale score matrix and panicked.

Adds regression tests for both the resolve_ptrs unit level and the
full scoring pipeline.
@dmtrKovalenko dmtrKovalenko merged commit 8c76a1b into main Jul 7, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants