Skip to content

Commit 13a1fee

Browse files
committed
Add checksum size to header checksum
1 parent 77eaeb0 commit 13a1fee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/io/CompressedInputStream.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@ void CompressedInputStream::readHeader()
273273
}
274274

275275
_ctx.putInt("bsVersion", bsVersion);
276+
uint64 ckSize = 0;
276277

277278
// Read block checksum
278279
if (bsVersion >= 6) {
279-
uint64 ckSize = _ibs->readBits(2);
280+
ckSize = _ibs->readBits(2);
280281

281282
if (ckSize == 1) {
282283
_hasher32 = new XXHash32(BITSTREAM_TYPE);
@@ -352,7 +353,9 @@ void CompressedInputStream::readHeader()
352353

353354
uint32 seed = (bsVersion <= 5 ? 1 : 0x01030507) * uint32(bsVersion);
354355
const uint32 HASH = 0x1E35A7BD;
356+
355357
uint32 cksum2 = HASH * seed;
358+
cksum2 ^= (HASH * uint32(~ckSize));
356359
cksum2 ^= (HASH * uint32(~_entropyType));
357360
cksum2 ^= (HASH * uint32((~_transformType) >> 32));
358361
cksum2 ^= (HASH * uint32(~_transformType));

src/io/CompressedOutputStream.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ void CompressedOutputStream::writeHeader()
296296
uint32 seed = 0x01030507 * BITSTREAM_FORMAT_VERSION; // no const to avoid VS2008 warning
297297
const uint32 HASH = 0x1E35A7BD;
298298
uint32 cksum = HASH * seed;
299+
cksum ^= (HASH * uint32(~ckSize));
299300
cksum ^= (HASH * uint32(~_entropyType));
300301
cksum ^= (HASH * uint32((~_transformType) >> 32));
301302
cksum ^= (HASH * uint32(~_transformType));

0 commit comments

Comments
 (0)