Skip to content

Commit 6f3bdab

Browse files
authored
pe.tls.tlsdata.parse_with_opts - integer overflow allows bypassing checks and triggering out of bound read (#448)
Co-authored-by: BinFlip <[email protected]>
1 parent d5ce06a commit 6f3bdab

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pe/tls.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,15 @@ impl<'a> TlsData<'a> {
227227
rva
228228
))
229229
})?;
230-
if offset + size as usize > bytes.len() {
230+
231+
let offset_end = offset.checked_add(size as usize).ok_or_else(|| {
232+
error::Error::Malformed(format!(
233+
"tls start_address_of_raw_data ({:#x}) + size_of_raw_data ({:#x}) casues an integer overflow",
234+
offset, size
235+
))
236+
})?;
237+
238+
if offset > bytes.len() || offset_end > bytes.len() {
231239
return Err(error::Error::Malformed(format!(
232240
"tls raw data offset ({:#x}) and size ({:#x}) greater than byte slice len ({:#x})",
233241
offset, size, bytes.len()

0 commit comments

Comments
 (0)