diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2022-03-31 00:50:51 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2022-03-31 00:52:40 +0200 |
commit | 08716954031eb0329fbd1ad2cd3fa593d3a046ab (patch) | |
tree | 48683dcf0639fbe7b84e00ea02dacaa4de9fe577 /src/Common/zlib/inflate.c | |
parent | 2be0b2e88ffebf9b63dcda4048ab0a24cd6ec131 (diff) | |
download | VeraCrypt-08716954031eb0329fbd1ad2cd3fa593d3a046ab.tar.gz VeraCrypt-08716954031eb0329fbd1ad2cd3fa593d3a046ab.zip |
Update zlib to version 1.2.12
Diffstat (limited to 'src/Common/zlib/inflate.c')
-rw-r--r-- | src/Common/zlib/inflate.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/Common/zlib/inflate.c b/src/Common/zlib/inflate.c index ac333e8c..7be8c636 100644 --- a/src/Common/zlib/inflate.c +++ b/src/Common/zlib/inflate.c @@ -1,3 +1,3 @@ /* inflate.c -- zlib decompression - * Copyright (C) 1995-2016 Mark Adler + * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -132,2 +132,3 @@ z_streamp strm; state->havedict = 0; + state->flags = -1; state->dmax = 32768U; @@ -449,6 +450,6 @@ unsigned copy; #ifdef GUNZIP -# define UPDATE(check, buf, len) \ +# define UPDATE_CHECK(check, buf, len) \ (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) #else -# define UPDATE(check, buf, len) adler32(check, buf, len) +# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len) #endif @@ -672,3 +673,2 @@ int flush; } - state->flags = 0; /* expect zlib header */ if (state->head != Z_NULL) @@ -699,2 +699,3 @@ int flush; state->dmax = 1U << len; + state->flags = 0; /* indicate zlib header */ Tracev((stderr, "inflate: zlib header ok\n")); @@ -724,2 +725,3 @@ int flush; state->mode = TIME; + /* fallthrough */ case TIME: @@ -732,2 +734,3 @@ int flush; state->mode = OS; + /* fallthrough */ case OS: @@ -742,2 +745,3 @@ int flush; state->mode = EXLEN; + /* fallthrough */ case EXLEN: @@ -755,2 +759,3 @@ int flush; state->mode = EXTRA; + /* fallthrough */ case EXTRA: @@ -777,2 +782,3 @@ int flush; state->mode = NAME; + /* fallthrough */ case NAME: @@ -798,2 +804,3 @@ int flush; state->mode = COMMENT; + /* fallthrough */ case COMMENT: @@ -818,2 +825,3 @@ int flush; state->mode = HCRC; + /* fallthrough */ case HCRC: @@ -841,2 +849,3 @@ int flush; state->mode = DICT; + /* fallthrough */ case DICT: @@ -848,4 +857,6 @@ int flush; state->mode = TYPE; + /* fallthrough */ case TYPE: if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + /* fallthrough */ case TYPEDO: @@ -900,4 +911,6 @@ int flush; if (flush == Z_TREES) goto inf_leave; + /* fallthrough */ case COPY_: state->mode = COPY; + /* fallthrough */ case COPY: @@ -937,2 +950,3 @@ int flush; state->mode = LENLENS; + /* fallthrough */ case LENLENS: @@ -958,2 +972,3 @@ int flush; state->mode = CODELENS; + /* fallthrough */ case CODELENS: @@ -1041,4 +1056,6 @@ int flush; if (flush == Z_TREES) goto inf_leave; + /* fallthrough */ case LEN_: state->mode = LEN; + /* fallthrough */ case LEN: @@ -1092,2 +1109,3 @@ int flush; state->mode = LENEXT; + /* fallthrough */ case LENEXT: @@ -1102,2 +1120,3 @@ int flush; state->mode = DIST; + /* fallthrough */ case DIST: @@ -1129,2 +1148,3 @@ int flush; state->mode = DISTEXT; + /* fallthrough */ case DISTEXT: @@ -1145,2 +1165,3 @@ int flush; state->mode = MATCH; + /* fallthrough */ case MATCH: @@ -1204,3 +1225,3 @@ int flush; strm->adler = state->check = - UPDATE(state->check, put - out, out); + UPDATE_CHECK(state->check, put - out, out); out = left; @@ -1220,2 +1241,3 @@ int flush; state->mode = LENGTH; + /* fallthrough */ case LENGTH: @@ -1223,3 +1245,3 @@ int flush; NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { + if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { strm->msg = (char *)"incorrect length check"; @@ -1233,2 +1255,3 @@ int flush; state->mode = DONE; + /* fallthrough */ case DONE: @@ -1242,2 +1265,3 @@ int flush; case SYNC: + /* fallthrough */ default: @@ -1267,3 +1291,3 @@ int flush; strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); + UPDATE_CHECK(state->check, strm->next_out - out, out); strm->data_type = (int)state->bits + (state->last ? 64 : 0) + @@ -1403,2 +1427,3 @@ z_streamp strm; unsigned len; /* number of bytes to look at or looked at */ + int flags; /* temporary to save header status */ unsigned long in, out; /* temporary to save total_in and total_out */ @@ -1435,2 +1460,7 @@ z_streamp strm; if (state->have != 4) return Z_DATA_ERROR; + if (state->flags == -1) + state->wrap = 0; /* if no header yet, treat as raw */ + else + state->wrap &= ~4; /* no point in computing a check value now */ + flags = state->flags; in = strm->total_in; out = strm->total_out; @@ -1438,2 +1468,3 @@ z_streamp strm; strm->total_in = in; strm->total_out = out; + state->flags = flags; state->mode = TYPE; @@ -1533,3 +1564,3 @@ int check; state = (struct inflate_state FAR *)strm->state; - if (check) + if (check && state->wrap) state->wrap |= 4; |