You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am scanning the pelite in the latest version with my own static analyzer tool.
Unsafe conversion found at: src/resources/mod.rs#L86
#[inline]fnslice_ws(&self,offset:u32) -> Result<&'a[u16]>{let offset = offset asusize;// Alignment checkingif !cfg!(feature = "unsafe_alignment") && offset &1 != 0{returnErr(Error::Misaligned);}// The name is prefixed by its length in wordslet len = self.section.get(offset..offset + 2).ok_or(Error::Bounds)?;let len = unsafe{*(len.as_ptr()as*constu16)}asusize;// Extract the name given its lengthlet name = self.section.get(offset + 2..offset + 2 + len *2).ok_or(Error::Bounds)?;let name = unsafe{ slice::from_raw_parts(name.as_ptr()as*constu16, len)};Ok(name)}
This unsound implementation would create a misalignment issues if the type size of len.as_ptr() is smaller than the type size of u16.
This would potentially cause undefined behaviors in Rust. If we further manipulate the problematic converted types, it would potentially lead to different consequences such as access out-of-bound. I am reporting this issue for your attention.
The text was updated successfully, but these errors were encountered:
Hi, I am scanning the pelite in the latest version with my own static analyzer tool.
Unsafe conversion found at: src/resources/mod.rs#L86
This unsound implementation would create a misalignment issues if the type size of
len.as_ptr()
is smaller than the type size ofu16
.This would potentially cause undefined behaviors in Rust. If we further manipulate the problematic converted types, it would potentially lead to different consequences such as access out-of-bound. I am reporting this issue for your attention.
The text was updated successfully, but these errors were encountered: