Skip to content

Commit

Permalink
[libromdata] EXEPrivate::addFields_PE_Export(): Fix bad bounds checking
Browse files Browse the repository at this point in the history
This caused some DLLs with ordinal-only exports to not show the export
tab, see issue GerbilSoft#437. Conversely, a malformed DLL with more names than
ordinals could cause a buffer overrun.
  • Loading branch information
DankRank committed Feb 4, 2025
1 parent 5fdd8af commit c397cfb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libromdata/Other/EXE_PE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,14 @@ int EXEPrivate::addFields_PE_Export(void)
const uint32_t rvaExpNameTbl = le32_to_cpu(pExpDirTbl->AddressOfNames);
const uint32_t szExpNameTbl = le32_to_cpu(pExpDirTbl->NumberOfNames);
const uint32_t *expNameTbl = reinterpret_cast<const uint32_t*>(
checkBounds(rvaExpNameTbl, szExpAddrTbl*sizeof(uint32_t)));
checkBounds(rvaExpNameTbl, szExpNameTbl*sizeof(uint32_t)));
if (!expNameTbl)
return -ENOENT;

// Export Ordinal Table
const uint32_t rvaExpOrdTbl = le32_to_cpu(pExpDirTbl->AddressOfNameOrdinals);
const uint16_t *expOrdTbl = reinterpret_cast<const uint16_t*>(
checkBounds(rvaExpOrdTbl, szExpAddrTbl*sizeof(uint16_t)));
checkBounds(rvaExpOrdTbl, szExpNameTbl*sizeof(uint16_t)));
if (!expOrdTbl)
return -ENOENT;

Expand Down

0 comments on commit c397cfb

Please sign in to comment.