cberner / fuser

Filesystem in Userspace (FUSE) for Rust
MIT License
836 stars 114 forks source link

Remove unsafe from the request parsing code #115

Closed wmanley closed 3 years ago

wmanley commented 3 years ago

Instead we use zerocopy::FromBytes.

Previously the code did not ensure alignment, which could lead to undefined behaviour. Now we do check alignment I've had to fix it in a few places using AlignedData<[u8; sz]> as a buffer in tests. Unfortunately we can't use Box<AlignedData<u8; BUFFER_SIZE>> as our main buffer because it's too large to create on the stack and Rust currently offers no way to allocate it directly on the heap. Instead we have to fiddle with offsets for the Vec.

wmanley commented 3 years ago

@cberner: I consider this mergable. Please let me know if you want any changes. There are no API changes here.

cberner commented 3 years ago

Great! I'll take a look soon

wmanley commented 3 years ago

Thanks for the review. I've fixed the issues and force-pushed.

cberner commented 3 years ago

Merged. Thanks!