Improve patch

Implement things pointed out by jreiser on review of the patch.
- Fix type conversion issue
- Added constant with comment
- Added comment for not validating UPX_RSIZE_MAX_MEM

Additional changes
- Honor the size of the export_dir_t when calculating the available
  space
This commit is contained in:
Thorsten Zachmann 2024-12-16 10:58:16 +01:00
parent 198fc1c107
commit 2e763c3b0e

View File

@ -1224,7 +1224,9 @@ void PeFile::Export::convert(unsigned eoffs, unsigned esize) {
size += len;
iv.add_interval(edir.name, len);
if (upx_uint64_t(edir.functions + edir.names) * 4 >= upx_uint64_t(esize)) {
// this check does not take UPX_RSIZE_MAX_MEM into account
const int ptr_size = 4; // size of function/name pointers
if ((upx_uint64_t(edir.functions) + upx_uint64_t(edir.names)) * ptr_size >= upx_uint64_t(esize - sizeof(export_dir_t))) {
throwInternalError("bad export directory, outside size");
}