Skip to content

fix: read_exact on an uninitialized buffer results in undefined behavior#8

Merged
nuskey8 merged 1 commit intomainfrom
fix/read_exact-ub
Mar 24, 2026
Merged

fix: read_exact on an uninitialized buffer results in undefined behavior#8
nuskey8 merged 1 commit intomainfrom
fix/read_exact-ub

Conversation

@nuskey8
Copy link
Copy Markdown
Owner

@nuskey8 nuskey8 commented Mar 24, 2026

read_exact can read the buffer it is passed to it, so passing an uninitialized buffer may result in undefined behavior.

Therefore, this PR will fix the issue by initializing the buffer to zero. While this will result in a very slight performance decrease, it is within acceptable limits.

This can be resolved by using read_buf_exact, but since this API is currently only available nightly, we will postpone this for now.

ref: https://users.rust-lang.org/t/zerompk-extremely-fast-messagepack-serializer-for-rust/139108/9?u=nuskey8

@nuskey8 nuskey8 merged commit d1ffdb1 into main Mar 24, 2026
@nuskey8 nuskey8 deleted the fix/read_exact-ub branch March 24, 2026 11:05
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