Check blocksize

This commit is contained in:
John Reiser
2015-05-09 20:29:56 -07:00
parent cb35ba4543
commit a8a3caed1c
+4
View File
@@ -565,6 +565,8 @@ void PackUnix::unpack(OutputFile *fo)
fi->seek(4, SEEK_CUR); fi->seek(4, SEEK_CUR);
} }
if ((int)(blocksize + OVERHEAD) < 0)
throwCantUnpack("blocksize corrupted");
ibuf.alloc(blocksize + OVERHEAD); ibuf.alloc(blocksize + OVERHEAD);
// decompress blocks // decompress blocks
@@ -595,6 +597,8 @@ void PackUnix::unpack(OutputFile *fo)
throwCompressedDataViolation(); throwCompressedDataViolation();
i = blocksize + OVERHEAD - sz_cpr; i = blocksize + OVERHEAD - sz_cpr;
if (i < 0)
throwCantUnpack("corrupt b_info");
fi->readx(buf+i, sz_cpr); fi->readx(buf+i, sz_cpr);
// update checksum of compressed data // update checksum of compressed data
c_adler = upx_adler32(buf + i, sz_cpr, c_adler); c_adler = upx_adler32(buf + i, sz_cpr, c_adler);