Modernize libc usage: stop using off_t, use modern printf.

C++ 14 is here, and old versions of MSVC and MSVCRT have
haunted us long enough.
This commit is contained in:
Markus F.X.J. Oberhumer
2021-01-05 18:52:05 +01:00
parent b4429e1a42
commit 700c8730cf
19 changed files with 130 additions and 1010 deletions
+4 -4
View File
@@ -286,10 +286,10 @@ int PackExe::readFileHeader()
}
ih_imagesize = ih_exesize - ih.headsize16*16;
ih_overlay = file_size - ih_exesize;
if (file_size < (int)sizeof(ih)
if (file_size_u < sizeof(ih)
|| ((ih.m512 | ih.p512) && ih.m512+ih.p512*512u < sizeof (ih)))
throwCantPack("illegal exe header");
if (file_size < (off_t)ih_exesize || ih_imagesize <= 0 || ih_imagesize > ih_exesize)
if (file_size_u < ih_exesize || ih_imagesize <= 0 || ih_imagesize > ih_exesize)
throwCantPack("exe header corrupted");
#if 0
printf("dos/exe header: %d %d %d\n", ih_exesize, ih_imagesize, ih_overlay);
@@ -674,10 +674,10 @@ int PackExe::canUnpack()
{
if (!readFileHeader())
return false;
const off_t off = ih.headsize16 * 16;
const unsigned off = ih.headsize16 * 16;
fi->seek(off, SEEK_SET);
bool b = readPackHeader(4096);
return b && (off + (off_t) ph.c_len <= file_size);
return b && (off + ph.c_len <= file_size_u);
}