Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FixedSizeBlock::interpret should either check alignment or use read_unaligned #198

Closed
afranchuk opened this issue Jun 21, 2024 · 1 comment
Labels
fix merged Fix is merged, but the issue will stay open until it's released.

Comments

@afranchuk
Copy link
Contributor

read is used here:

let block = unsafe { block_ptr.read() }.from_le();

However the alignment hasn't been verified prior to this. It so happens that FixedSizeBlock is (currently) only implemented on repr(packed) structs (which have 1-byte alignment), however the alignment should still be verified or read_unaligned should be used.

If these should always be repr(packed), maybe add an assert_eq!(std::mem::align_of::<Self>(), 1)?

@afranchuk
Copy link
Contributor Author

The same can be said for

out_ptr.write(self);

Pr0methean added a commit that referenced this issue Jun 22, 2024
@Pr0methean Pr0methean added the fix merged Fix is merged, but the issue will stay open until it's released. label Jun 22, 2024
@Pr0methean Pr0methean added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix merged Fix is merged, but the issue will stay open until it's released.
Projects
None yet
Development

No branches or pull requests

2 participants