mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-03 10:31:28 -05:00
fix(windows): preserve companion export tables
Guard PE32 export copies when the companion omits plaintext stub data. Reserve the complete export directory during compaction and validate file backing before overlaying it to prevent writes into the next section. Add regression coverage for zero-filled export space, invalid directory ranges, and truncated source or destination sections.
This commit is contained in:
1 parent
5bd1b0b07d
commit
6e233bbf18
3 files changed
+105
-12
No files matched your search
@@ -823,7 +823,15 @@ impl<'a> Unpacker<'a> {
|
||||
let d = export_va as usize;
|
||||
let s = export_file_off as usize;
|
||||
let n = export_size as usize;
|
||||
self.decompressed[d..d + n].copy_from_slice(&self.file_data[s..s + n]);
|
||||
// Spliced companions may omit the stub's plaintext exports;
|
||||
// the I/O adapter overlays those from the original stub later.
|
||||
if s.checked_add(n)
|
||||
.is_some_and(|end| end <= self.file_data.len())
|
||||
&& d.checked_add(n)
|
||||
.is_some_and(|end| end <= self.decompressed.len())
|
||||
{
|
||||
self.decompressed[d..d + n].copy_from_slice(&self.file_data[s..s + n]);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- .text decrypt with decrypt_data8 (PE32 auto-detected formula) ----
|
||||
|
||||
Reference in new issue
Block a user