Corrected a bug in exeflat: it was writing 32 bytes too many from possibly

unexisting buffers after compressing exe files.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1480 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-07-07 13:51:54 +00:00
parent d6b54e78d0
commit 66f65090dd

View File

@ -210,13 +210,14 @@ static int exeflat(const char *srcfile, const char *dstfile,
printf("Compressing kernel - %s format\n", (compress_sys_file)?"sys":"exe");
}
if (UPX && !compress_sys_file) {
ULONG realsize;
/* write header without relocations to file */
exe_header nheader = *header;
nheader.exRelocItems = 0;
nheader.exHeaderSize = 2;
size += 32;
nheader.exPages = (UWORD)(size >> 9);
nheader.exExtraBytes = (UWORD)size & 511;
realsize = size + 32;
nheader.exPages = (UWORD)(realsize >> 9);
nheader.exExtraBytes = (UWORD)realsize & 511;
if (nheader.exExtraBytes)
nheader.exPages++;
if (fwrite(&nheader, sizeof(nheader), 1, dest) != 1) {