Skip to content

avoid usize overflow when sizing scratch buffers in yescrypt_body#907

Open
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:yescrypt-scratch-overflow
Open

avoid usize overflow when sizing scratch buffers in yescrypt_body#907
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:yescrypt-scratch-overflow

Conversation

@dxbjavid
Copy link
Copy Markdown

@dxbjavid dxbjavid commented Jun 1, 2026

The scratch buffers in yescrypt_body are sized with 32 * (r as usize) * (n as usize) and friends. r/n/p come from a parsed $y$ hash, and on 32-bit targets that multiply wraps even though the u64 validation just above passes: classic-mode n=65536, r=32768 makes 32*r*n reach 2^36, wrapping to 0 so V becomes vec![0; 0] and smix1 writes past it (debug builds panic on the overflow). Compute the lengths in u64, already bounded by the checks, and convert with usize::try_from like the existing n cast.

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.

1 participant