Skip to content

Commit

Permalink
Fix panic on malformed callbacks may cause subtract with overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kkent030315 committed Oct 29, 2024
1 parent a721adb commit 8368e22
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pe/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ impl<'a> TlsData<'a> {
if callback == 0 {
break;
}
if callback < image_base as u64 {
return Err(error::Error::Malformed(format!(
"cannot map tls callback ({:#x})",
callback
)));
}
// Each callback is an VA so convert it to RVA
let callback_rva = callback as usize - image_base;
// Check if the callback is in the image
Expand Down

0 comments on commit 8368e22

Please sign in to comment.