Skip to content

Commit

Permalink
Check if an entry in the TLS callback list is the terminator before t…
Browse files Browse the repository at this point in the history
…rying to load it

This fixes issue #412.
  • Loading branch information
gabrielesvelto committed Jun 11, 2024
1 parent 6177758 commit 52a8069
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pe/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ impl<'a> TlsData<'a> {
} else {
bytes.pread_with::<u32>(offset + i * 4, scroll::LE)? as u64
};

if callback == 0 {
break;
}

// 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 All @@ -236,9 +241,6 @@ impl<'a> TlsData<'a> {
callback
)));
}
if callback == 0 {
break;
}
callbacks.push(callback);
i += 1;
}
Expand Down

0 comments on commit 52a8069

Please sign in to comment.