exeflat: document UPX 3.96 exact DOS/SYS limit but use a lower number

This commit is contained in:
C. Masloch 2022-05-26 11:28:48 +02:00 committed by Kenneth J Davis
parent f23f035554
commit 77d3c7e1d7

View File

@ -220,10 +220,17 @@ static int exeflat(const char *srcfile, const char *dstfile,
exit(1);
}
/* The biggest .sys file that UPX accepts seems to be 65419 bytes long */
/* The biggest .sys file that UPX accepts seems to be 65419 bytes long.
Actually, UPX 3.96 appears to accept DOS/SYS files up to 65426 bytes.
To avoid problems we use a slightly lower limit. */
if (UPX) {
if (stubdevsize && stubexesize)
compress_sys_file = (size - (0x20 - 0x10)) < 65420;
compress_sys_file = (size - stubdevsize) <= /* 65426 */ 65400;
/* would need to subtract 0x10 for the device header here
but then add in the same, because we skip 0x10 bytes
of the source file but fill the same length with the
doctored device header. so (size - stubdevsize) gives
the exact result that we want to compare against. */
else if (stubexesize)
compress_sys_file = 0;
else if (stubdevsize)