diff options
| author | quackottu <224479491+quackottu@users.noreply.github.com> | 2026-11-22 12:48:35 +0530 |
|---|---|---|
| committer | quackottu <224479491+quackottu@users.noreply.github.com> | 2026-11-22 12:48:35 +0530 |
| commit | 236b0acec3891b773ead57d3113b2f469d0e4a9f (patch) | |
| tree | beeaa4ed1f7b1ffa6e86d8bf3bc1b536b596cdc0 /runtime/test/loader_test.cpp | |
| parent | c63773d51235d72250d48699f29830ac9ddafd60 (diff) | |
pe_loader: honour NumberOfRvaAndSizes, and refuse a forwarder ordinal past 65535
Data directories past NumberOfRvaAndSizes were read anyway (only the
exception directory checked the count), so stale bytes there were parsed
as import, delay-import, export or relocation tables. And resolve_forwarder
range-checked the ordinal before adding each digit, so '#65537' passed and
was cast to ordinal 1. The hand-built test images now declare their 16
directories.
Diffstat (limited to 'runtime/test/loader_test.cpp')
| -rw-r--r-- | runtime/test/loader_test.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/runtime/test/loader_test.cpp b/runtime/test/loader_test.cpp index 5ee203e28..84ade94b0 100644 --- a/runtime/test/loader_test.cpp +++ b/runtime/test/loader_test.cpp | |||
| @@ -61,6 +61,7 @@ std::vector<uint8_t> make_image() { | |||
| 61 | nt->OptionalHeader.SizeOfHeaders = 0x200; | 61 | nt->OptionalHeader.SizeOfHeaders = 0x200; |
| 62 | nt->OptionalHeader.SizeOfImage = 0x2000; | 62 | nt->OptionalHeader.SizeOfImage = 0x2000; |
| 63 | nt->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI; | 63 | nt->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI; |
| 64 | nt->OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; | ||
| 64 | auto* sec = IMAGE_FIRST_SECTION(nt); | 65 | auto* sec = IMAGE_FIRST_SECTION(nt); |
| 65 | std::memcpy(sec->Name, ".text", 6); | 66 | std::memcpy(sec->Name, ".text", 6); |
| 66 | sec->VirtualAddress = 0x1000; | 67 | sec->VirtualAddress = 0x1000; |