diff --git a/lib/zlib/inflate.js b/lib/zlib/inflate.js index 3d4a740..2c29675 100644 --- a/lib/zlib/inflate.js +++ b/lib/zlib/inflate.js @@ -1356,8 +1356,8 @@ function inflate(strm, flush) { while (bits < 32) { if (have === 0) { break inf_leave; } have--; - hold += input[next++] << bits; - hold >>>= 0; + // Use '|' insdead of '+' to make sure that result is signed + hold |= input[next++] << bits; bits += 8; } //===// @@ -1371,7 +1371,8 @@ function inflate(strm, flush) { } _out = left; - if ((state.flags ? hold : ZSWAP32(hold) >>> 0) !== state.check >>> 0) { + // NB: crc32 stored as signed 32-bit int, ZSWAP32 returns signed too + if ((state.flags ? hold : ZSWAP32(hold)) !== state.check) { strm.msg = 'incorrect data check'; state.mode = BAD; break;