1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Must not compare orig_file_size with fi->st_size() during ::unpack

This commit is contained in:
John Reiser 2015-05-09 17:47:17 -07:00
parent b182b50f24
commit 83ce7dc62f
2 changed files with 3 additions and 5 deletions

View File

@ -3014,8 +3014,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
p_info hbuf; fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_te32(&hbuf.p_filesize);
blocksize = get_te32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size
|| orig_file_size > fi->st_size())
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("p_info corrupted");
ibuf.alloc(blocksize + OVERHEAD);
@ -3534,8 +3533,7 @@ void PackLinuxElf32::unpack(OutputFile *fo)
p_info hbuf; fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_te32(&hbuf.p_filesize);
blocksize = get_te32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size
|| orig_file_size > fi->st_size())
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("p_info corrupted");
ibuf.alloc(blocksize + OVERHEAD);

View File

@ -556,7 +556,7 @@ void PackUnix::unpack(OutputFile *fo)
orig_file_size = get_te32(&hbuf.p_filesize);
blocksize = get_te32(&hbuf.p_blocksize);
if (file_size != (off_t)orig_file_size || blocksize > orig_file_size)
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("file header corrupted");
}
else