silicon icon indicating copy to clipboard operation
silicon copied to clipboard

Unsoundness of `gaussian_blur`

Open shinmao opened this issue 5 months ago • 0 comments

I consider the gaussian_blur have the unsound implementation in line 32 https://github.com/Aloxaf/silicon/blob/7837ec85e40a368d5fe0a61c47b5ad0be60359dd/src/blur.rs#L23-L33 Since RgbaImage is a struct with repr(Rust), it means that it has an unstable layout and compiler preserves the right to insert any padding bytes around the fields. When you cast the raw pointer of it to the pointer of Vec<u8>, it could lead to incorrect data interpretation and uninitialized memory exposure since Vec<u8> expects there are continuous bytes.

shinmao avatar Sep 04 '24 01:09 shinmao