Skip to content

Commit

Permalink
Don't bother computing check value after successful inflateSync().
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Jun 10, 2022
1 parent a194382 commit 77f1c17
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/zlib/inflate.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ function InflateState() {
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.flags = 0; /* gzip header method and flags (0 if zlib), or
-1 if raw or no header yet */
this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
this.check = 0; /* protected copy of check value */
this.total = 0; /* protected copy of output count */
Expand Down Expand Up @@ -184,6 +185,7 @@ const inflateResetKeep = (strm) => {
state.mode = HEAD;
state.last = 0;
state.havedict = 0;
state.flags = -1;
state.dmax = 32768;
state.head = null/*Z_NULL*/;
state.hold = 0;
Expand Down Expand Up @@ -464,7 +466,6 @@ const inflate = (strm, flush) => {
state.mode = FLAGS;
break;
}
state.flags = 0; /* expect zlib header */
if (state.head) {
state.head.done = false;
}
Expand Down Expand Up @@ -498,6 +499,7 @@ const inflate = (strm, flush) => {
state.dmax = 1 << state.wbits;
//state.dmax = 1 << len;

state.flags = 0; /* indicate zlib header */
//Tracev((stderr, "inflate: zlib header ok\n"));
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
state.mode = hold & 0x200 ? DICTID : TYPE;
Expand Down Expand Up @@ -1408,7 +1410,7 @@ const inflate = (strm, flush) => {
bits += 8;
}
//===//
if (hold !== (state.total & 0xffffffff)) {
if ((state.wrap & 4) && hold !== (state.total & 0xffffffff)) {
strm.msg = 'incorrect length check';
state.mode = BAD;
break;
Expand Down

0 comments on commit 77f1c17

Please sign in to comment.