mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-03 02:10:57 +01:00
Add option to not compute or check check values.
9852c209ac
+ added macro renaming in53ce271311
This commit is contained in:
parent
8f630ba374
commit
024d11ee5f
1 changed files with 17 additions and 15 deletions
|
@ -100,7 +100,8 @@ const zswap32 = (q) => {
|
|||
function InflateState() {
|
||||
this.mode = 0; /* current inflate mode */
|
||||
this.last = false; /* true if processing last block */
|
||||
this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||
bit 2 true to validate check value */
|
||||
this.havedict = false; /* true if dictionary provided */
|
||||
this.flags = 0; /* gzip header method and flags (0 if zlib) */
|
||||
this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
|
||||
|
@ -208,7 +209,7 @@ const inflateReset2 = (strm, windowBits) => {
|
|||
windowBits = -windowBits;
|
||||
}
|
||||
else {
|
||||
wrap = (windowBits >> 4) + 1;
|
||||
wrap = (windowBits >> 4) + 5;
|
||||
if (windowBits < 48) {
|
||||
windowBits &= 15;
|
||||
}
|
||||
|
@ -511,7 +512,7 @@ const inflate = (strm, flush) => {
|
|||
if (state.head) {
|
||||
state.head.text = ((hold >> 8) & 1);
|
||||
}
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
//=== CRC2(state.check, hold);
|
||||
hbuf[0] = hold & 0xff;
|
||||
hbuf[1] = (hold >>> 8) & 0xff;
|
||||
|
@ -536,7 +537,7 @@ const inflate = (strm, flush) => {
|
|||
if (state.head) {
|
||||
state.head.time = hold;
|
||||
}
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
//=== CRC4(state.check, hold)
|
||||
hbuf[0] = hold & 0xff;
|
||||
hbuf[1] = (hold >>> 8) & 0xff;
|
||||
|
@ -564,7 +565,7 @@ const inflate = (strm, flush) => {
|
|||
state.head.xflags = (hold & 0xff);
|
||||
state.head.os = (hold >> 8);
|
||||
}
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
//=== CRC2(state.check, hold);
|
||||
hbuf[0] = hold & 0xff;
|
||||
hbuf[1] = (hold >>> 8) & 0xff;
|
||||
|
@ -591,7 +592,7 @@ const inflate = (strm, flush) => {
|
|||
if (state.head) {
|
||||
state.head.extra_len = hold;
|
||||
}
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
//=== CRC2(state.check, hold);
|
||||
hbuf[0] = hold & 0xff;
|
||||
hbuf[1] = (hold >>> 8) & 0xff;
|
||||
|
@ -633,7 +634,7 @@ const inflate = (strm, flush) => {
|
|||
// len + copy > state.head.extra_max ?
|
||||
// state.head.extra_max - len : copy);
|
||||
}
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
state.check = crc32(state.check, input, copy, next);
|
||||
}
|
||||
have -= copy;
|
||||
|
@ -659,7 +660,7 @@ const inflate = (strm, flush) => {
|
|||
}
|
||||
} while (len && copy < have);
|
||||
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
state.check = crc32(state.check, input, copy, next);
|
||||
}
|
||||
have -= copy;
|
||||
|
@ -684,7 +685,7 @@ const inflate = (strm, flush) => {
|
|||
state.head.comment += String.fromCharCode(len);
|
||||
}
|
||||
} while (len && copy < have);
|
||||
if (state.flags & 0x0200) {
|
||||
if ((state.flags & 0x0200) && (state.wrap & 4)) {
|
||||
state.check = crc32(state.check, input, copy, next);
|
||||
}
|
||||
have -= copy;
|
||||
|
@ -706,7 +707,7 @@ const inflate = (strm, flush) => {
|
|||
bits += 8;
|
||||
}
|
||||
//===//
|
||||
if (hold !== (state.check & 0xffff)) {
|
||||
if ((state.wrap & 4) && hold !== (state.check & 0xffff)) {
|
||||
strm.msg = 'header crc mismatch';
|
||||
state.mode = BAD;
|
||||
break;
|
||||
|
@ -1359,15 +1360,15 @@ const inflate = (strm, flush) => {
|
|||
_out -= left;
|
||||
strm.total_out += _out;
|
||||
state.total += _out;
|
||||
if (_out) {
|
||||
if ((state.wrap & 4) && _out) {
|
||||
strm.adler = state.check =
|
||||
/*UPDATE(state.check, put - _out, _out);*/
|
||||
/*UPDATE_CHECK(state.check, put - _out, _out);*/
|
||||
(state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
|
||||
|
||||
}
|
||||
_out = left;
|
||||
// NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
||||
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
||||
if ((state.wrap & 4) && (state.flags ? hold : zswap32(hold)) !== state.check) {
|
||||
strm.msg = 'incorrect data check';
|
||||
state.mode = BAD;
|
||||
break;
|
||||
|
@ -1448,8 +1449,8 @@ const inflate = (strm, flush) => {
|
|||
strm.total_in += _in;
|
||||
strm.total_out += _out;
|
||||
state.total += _out;
|
||||
if (state.wrap && _out) {
|
||||
strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
||||
if ((state.wrap & 4) && _out) {
|
||||
strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
|
||||
(state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
|
||||
}
|
||||
strm.data_type = state.bits + (state.last ? 64 : 0) +
|
||||
|
@ -1548,4 +1549,5 @@ module.exports.inflatePrime = inflatePrime;
|
|||
module.exports.inflateSync = inflateSync;
|
||||
module.exports.inflateSyncPoint = inflateSyncPoint;
|
||||
module.exports.inflateUndermine = inflateUndermine;
|
||||
module.exports.inflateValidate = inflateValidate;
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue