Toshaan Bharvani
11 months ago
13 changed files with 3611 additions and 131 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
From 5eaae2af0defeca148c2a281873bb31a15246876 Mon Sep 17 00:00:00 2001 |
||||
From: Ilya Leoshkevich <iii@linux.ibm.com> |
||||
Date: Thu, 2 Feb 2023 19:34:24 +0100 |
||||
Subject: [PATCH] 2155328 |
||||
|
||||
--- |
||||
contrib/s390/dfltcc.c | 21 +++++++++++++++------ |
||||
1 file changed, 15 insertions(+), 6 deletions(-) |
||||
|
||||
diff --git a/contrib/s390/dfltcc.c b/contrib/s390/dfltcc.c |
||||
index 72099e7..f8dc21c 100644 |
||||
--- a/contrib/s390/dfltcc.c |
||||
+++ b/contrib/s390/dfltcc.c |
||||
@@ -456,7 +456,10 @@ again: |
||||
*strm->next_out = (Bytef)state->bi_buf; |
||||
/* Honor history and check value */ |
||||
param->nt = 0; |
||||
- param->cv = state->wrap == 2 ? ZSWAP32(strm->adler) : strm->adler; |
||||
+ if (state->wrap == 1) |
||||
+ param->cv = strm->adler; |
||||
+ else if (state->wrap == 2) |
||||
+ param->cv = ZSWAP32(strm->adler); |
||||
|
||||
/* When opening a block, choose a Huffman-Table Type */ |
||||
if (!param->bcf) { |
||||
@@ -488,7 +491,10 @@ again: |
||||
state->bi_buf = 0; /* Avoid accessing next_out */ |
||||
else |
||||
state->bi_buf = *strm->next_out & ((1 << state->bi_valid) - 1); |
||||
- strm->adler = state->wrap == 2 ? ZSWAP32(param->cv) : param->cv; |
||||
+ if (state->wrap == 1) |
||||
+ strm->adler = param->cv; |
||||
+ else if (state->wrap == 2) |
||||
+ strm->adler = ZSWAP32(param->cv); |
||||
|
||||
/* Unmask the input data */ |
||||
strm->avail_in += masked_avail_in; |
||||
@@ -600,11 +606,12 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(strm, flush, ret) |
||||
} |
||||
|
||||
/* Translate stream to parameter block */ |
||||
- param->cvt = state->flags ? CVT_CRC32 : CVT_ADLER32; |
||||
+ param->cvt = ((state->wrap & 4) && state->flags) ? CVT_CRC32 : CVT_ADLER32; |
||||
param->sbb = state->bits; |
||||
if (param->hl) |
||||
param->nt = 0; /* Honor history for the first block */ |
||||
- param->cv = state->flags ? ZSWAP32(state->check) : state->check; |
||||
+ if (state->wrap & 4) |
||||
+ param->cv = state->flags ? ZSWAP32(state->check) : state->check; |
||||
|
||||
/* Inflate */ |
||||
do { |
||||
@@ -615,7 +622,9 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(strm, flush, ret) |
||||
strm->msg = oesc_msg(dfltcc_state->msg, param->oesc); |
||||
state->last = cc == DFLTCC_CC_OK; |
||||
state->bits = param->sbb; |
||||
- strm->adler = state->check = state->flags ? ZSWAP32(param->cv) : param->cv; |
||||
+ if (state->wrap & 4) |
||||
+ strm->adler = state->check = state->flags ? |
||||
+ ZSWAP32(param->cv) : param->cv; |
||||
if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { |
||||
/* Report an error if stream is corrupted */ |
||||
state->mode = BAD; |
||||
@@ -1077,4 +1086,4 @@ int ZLIB_INTERNAL dfltcc_inflate_get_dictionary(strm, dictionary, dict_length) |
||||
if (dict_length) |
||||
*dict_length = param->hl; |
||||
return Z_OK; |
||||
-} |
||||
\ No newline at end of file |
||||
+} |
||||
-- |
||||
2.39.1 |
||||
|
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
From 480b65cae6c20a41aa698a6c9d3b260f6f744004 Mon Sep 17 00:00:00 2001 |
||||
From: Ilya Leoshkevich <iii@linux.ibm.com> |
||||
Date: Thu, 2 Feb 2023 19:41:32 +0100 |
||||
Subject: [PATCH] 0003-PATCH-Fix-clang-s-behavior-on-versions-7.patch |
||||
|
||||
--- |
||||
contrib/power/clang_workaround.h | 15 ++++++++++----- |
||||
1 file changed, 10 insertions(+), 5 deletions(-) |
||||
|
||||
diff --git a/contrib/power/clang_workaround.h b/contrib/power/clang_workaround.h |
||||
index b5e7dae..915f7e5 100644 |
||||
--- a/contrib/power/clang_workaround.h |
||||
+++ b/contrib/power/clang_workaround.h |
||||
@@ -39,7 +39,12 @@ __vector unsigned long long __builtin_pack_vector (unsigned long __a, |
||||
return __v; |
||||
} |
||||
|
||||
-#ifndef vec_xxpermdi |
||||
+/* |
||||
+ * Clang 7 changed the behavior of vec_xxpermdi in order to provide the same |
||||
+ * behavior of GCC. That means code adapted to Clang >= 7 does not work on |
||||
+ * Clang <= 6. So, fallback to __builtin_unpack_vector() on Clang <= 6. |
||||
+ */ |
||||
+#if !defined vec_xxpermdi || __clang_major__ <= 6 |
||||
|
||||
static inline |
||||
unsigned long __builtin_unpack_vector (__vector unsigned long long __v, |
||||
@@ -62,9 +67,9 @@ static inline |
||||
unsigned long __builtin_unpack_vector_0 (__vector unsigned long long __v) |
||||
{ |
||||
#if defined(__BIG_ENDIAN__) |
||||
- return vec_xxpermdi(__v, __v, 0x0)[1]; |
||||
- #else |
||||
return vec_xxpermdi(__v, __v, 0x0)[0]; |
||||
+ #else |
||||
+ return vec_xxpermdi(__v, __v, 0x3)[0]; |
||||
#endif |
||||
} |
||||
|
||||
@@ -72,9 +77,9 @@ static inline |
||||
unsigned long __builtin_unpack_vector_1 (__vector unsigned long long __v) |
||||
{ |
||||
#if defined(__BIG_ENDIAN__) |
||||
- return vec_xxpermdi(__v, __v, 0x3)[1]; |
||||
- #else |
||||
return vec_xxpermdi(__v, __v, 0x3)[0]; |
||||
+ #else |
||||
+ return vec_xxpermdi(__v, __v, 0x0)[0]; |
||||
#endif |
||||
} |
||||
#endif /* vec_xxpermdi */ |
||||
-- |
||||
2.39.1 |
||||
|
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
--- a/compress.c |
||||
+++ b/compress.c |
||||
@@ -5,9 +5,15 @@ |
||||
|
||||
/* @(#) $Id$ */ |
||||
|
||||
-#define ZLIB_INTERNAL |
||||
+#include "zutil.h" |
||||
#include "zlib.h" |
||||
|
||||
+#ifdef DFLTCC |
||||
+# include "contrib/s390/dfltcc.h" |
||||
+#else |
||||
+#define DEFLATE_BOUND_COMPLEN(source_len) 0 |
||||
+#endif |
||||
+ |
||||
/* =========================================================================== |
||||
Compresses the source buffer into the destination buffer. The level |
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte |
||||
@@ -81,6 +87,12 @@ int ZEXPORT compress (dest, destLen, source, sourceLen) |
||||
uLong ZEXPORT compressBound (sourceLen) |
||||
uLong sourceLen; |
||||
{ |
||||
+ uLong complen = DEFLATE_BOUND_COMPLEN(sourceLen); |
||||
+ |
||||
+ if (complen > 0) |
||||
+ /* Architecture-specific code provided an upper bound. */ |
||||
+ return complen + ZLIB_WRAPLEN; |
||||
+ |
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
||||
(sourceLen >> 25) + 13; |
||||
} |
||||
--- a/contrib/s390/dfltcc.h |
||||
+++ b/contrib/s390/dfltcc.h |
||||
@@ -12,6 +12,28 @@ void ZLIB_INTERNAL dfltcc_reset OF((z_streamp strm, uInt size)); |
||||
voidpf ZLIB_INTERNAL dfltcc_alloc_window OF((z_streamp strm, uInt items, |
||||
uInt size)); |
||||
void ZLIB_INTERNAL dfltcc_free_window OF((z_streamp strm, voidpf w)); |
||||
+#define DFLTCC_BLOCK_HEADER_BITS 3 |
||||
+#define DFLTCC_HLITS_COUNT_BITS 5 |
||||
+#define DFLTCC_HDISTS_COUNT_BITS 5 |
||||
+#define DFLTCC_HCLENS_COUNT_BITS 4 |
||||
+#define DFLTCC_MAX_HCLENS 19 |
||||
+#define DFLTCC_HCLEN_BITS 3 |
||||
+#define DFLTCC_MAX_HLITS 286 |
||||
+#define DFLTCC_MAX_HDISTS 30 |
||||
+#define DFLTCC_MAX_HLIT_HDIST_BITS 7 |
||||
+#define DFLTCC_MAX_SYMBOL_BITS 16 |
||||
+#define DFLTCC_MAX_EOBS_BITS 15 |
||||
+#define DFLTCC_MAX_PADDING_BITS 7 |
||||
+#define DEFLATE_BOUND_COMPLEN(source_len) \ |
||||
+ ((DFLTCC_BLOCK_HEADER_BITS + \ |
||||
+ DFLTCC_HLITS_COUNT_BITS + \ |
||||
+ DFLTCC_HDISTS_COUNT_BITS + \ |
||||
+ DFLTCC_HCLENS_COUNT_BITS + \ |
||||
+ DFLTCC_MAX_HCLENS * DFLTCC_HCLEN_BITS + \ |
||||
+ (DFLTCC_MAX_HLITS + DFLTCC_MAX_HDISTS) * DFLTCC_MAX_HLIT_HDIST_BITS + \ |
||||
+ (source_len) * DFLTCC_MAX_SYMBOL_BITS + \ |
||||
+ DFLTCC_MAX_EOBS_BITS + \ |
||||
+ DFLTCC_MAX_PADDING_BITS) >> 3) |
||||
int ZLIB_INTERNAL dfltcc_can_inflate OF((z_streamp strm)); |
||||
typedef enum { |
||||
DFLTCC_INFLATE_CONTINUE, |
||||
diff --git a/contrib/s390/dfltcc_deflate.h b/contrib/s390/dfltcc_deflate.h |
||||
index 03f7f53..46acfc5 100644 |
||||
--- a/contrib/s390/dfltcc_deflate.h |
||||
+++ b/contrib/s390/dfltcc_deflate.h |
||||
@@ -46,8 +46,7 @@ int ZLIB_INTERNAL dfltcc_deflate_get_dictionary OF((z_streamp strm, |
||||
#define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \ |
||||
do { \ |
||||
if (dfltcc_can_deflate((strm))) \ |
||||
- (complen) = (3 + 5 + 5 + 4 + 19 * 3 + (286 + 30) * 7 + \ |
||||
- (source_len) * 16 + 15 + 7) >> 3; \ |
||||
+ (complen) = DEFLATE_BOUND_COMPLEN(source_len); \ |
||||
} while (0) |
||||
#define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) (dfltcc_can_deflate((strm))) |
||||
#define DEFLATE_HOOK dfltcc_deflate |
||||
diff --git a/zutil.h b/zutil.h |
||||
index 14277bc..cf90e49 100644 |
||||
--- a/zutil.h |
||||
+++ b/zutil.h |
||||
@@ -87,6 +87,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ |
||||
|
||||
+#define ZLIB_WRAPLEN 6 /* zlib format overhead */ |
||||
+ |
||||
/* target dependencies */ |
||||
|
||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
--- a/contrib/s390/dfltcc.c |
||||
+++ b/contrib/s390/dfltcc.c |
||||
@@ -623,7 +623,7 @@ |
||||
state->bits = param->sbb; |
||||
state->whave = param->hl; |
||||
state->wnext = (param->ho + param->hl) & ((1 << HB_BITS) - 1); |
||||
- state->check = state->flags ? ZSWAP32(param->cv) : param->cv; |
||||
+ strm->adler = state->check = state->flags ? ZSWAP32(param->cv) : param->cv; |
||||
if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { |
||||
/* Report an error if stream is corrupted */ |
||||
state->mode = BAD; |
@ -0,0 +1,299 @@
@@ -0,0 +1,299 @@
|
||||
--- a/contrib/s390/dfltcc.c |
||||
+++ b/contrib/s390/dfltcc.c |
||||
@@ -539,10 +539,6 @@ int ZLIB_INTERNAL dfltcc_can_inflate(strm) |
||||
struct inflate_state FAR *state = (struct inflate_state FAR *)strm->state; |
||||
struct dfltcc_state FAR *dfltcc_state = GET_DFLTCC_STATE(state); |
||||
|
||||
- /* Unsupported compression settings */ |
||||
- if (state->wbits != HB_BITS) |
||||
- return 0; |
||||
- |
||||
/* Unsupported hardware */ |
||||
return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) && |
||||
is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0); |
||||
@@ -606,8 +602,6 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(strm, flush, ret) |
||||
/* Translate stream to parameter block */ |
||||
param->cvt = state->flags ? CVT_CRC32 : CVT_ADLER32; |
||||
param->sbb = state->bits; |
||||
- param->hl = state->whave; /* Software and hardware history formats match */ |
||||
- param->ho = (state->wnext - state->whave) & ((1 << HB_BITS) - 1); |
||||
if (param->hl) |
||||
param->nt = 0; /* Honor history for the first block */ |
||||
param->cv = state->flags ? ZSWAP32(state->check) : state->check; |
||||
@@ -621,8 +615,6 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(strm, flush, ret) |
||||
strm->msg = oesc_msg(dfltcc_state->msg, param->oesc); |
||||
state->last = cc == DFLTCC_CC_OK; |
||||
state->bits = param->sbb; |
||||
- state->whave = param->hl; |
||||
- state->wnext = (param->ho + param->hl) & ((1 << HB_BITS) - 1); |
||||
strm->adler = state->check = state->flags ? ZSWAP32(param->cv) : param->cv; |
||||
if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { |
||||
/* Report an error if stream is corrupted */ |
||||
@@ -644,11 +636,52 @@ int ZLIB_INTERNAL dfltcc_was_inflate_used(strm) |
||||
return !param->nt; |
||||
} |
||||
|
||||
+/* |
||||
+ Rotates a circular buffer. |
||||
+ The implementation is based on https://cplusplus.com/reference/algorithm/rotate/ |
||||
+ */ |
||||
+local void rotate OF((Bytef *start, Bytef *pivot, Bytef *end)); |
||||
+local void rotate(start, pivot, end) |
||||
+ Bytef *start; |
||||
+ Bytef *pivot; |
||||
+ Bytef *end; |
||||
+{ |
||||
+ Bytef *p = pivot; |
||||
+ Bytef tmp; |
||||
+ |
||||
+ while (p != start) { |
||||
+ tmp = *start; |
||||
+ *start = *p; |
||||
+ *p = tmp; |
||||
+ |
||||
+ start++; |
||||
+ p++; |
||||
+ |
||||
+ if (p == end) |
||||
+ p = pivot; |
||||
+ else if (start == pivot) |
||||
+ pivot = p; |
||||
+ } |
||||
+} |
||||
+ |
||||
+#define MIN(x, y) ({ \ |
||||
+ typeof(x) _x = (x); \ |
||||
+ typeof(y) _y = (y); \ |
||||
+ _x < _y ? _x : _y; \ |
||||
+}) |
||||
+ |
||||
+#define MAX(x, y) ({ \ |
||||
+ typeof(x) _x = (x); \ |
||||
+ typeof(y) _y = (y); \ |
||||
+ _x > _y ? _x : _y; \ |
||||
+}) |
||||
+ |
||||
int ZLIB_INTERNAL dfltcc_inflate_disable(strm) |
||||
z_streamp strm; |
||||
{ |
||||
struct inflate_state FAR *state = (struct inflate_state FAR *)strm->state; |
||||
struct dfltcc_state FAR *dfltcc_state = GET_DFLTCC_STATE(state); |
||||
+ struct dfltcc_param_v0 *param = &dfltcc_state->param; |
||||
|
||||
if (!dfltcc_can_inflate(strm)) |
||||
return 0; |
||||
@@ -660,6 +693,9 @@ int ZLIB_INTERNAL dfltcc_inflate_disable(strm) |
||||
return 1; |
||||
/* DFLTCC was not used yet - decompress in software */ |
||||
memset(&dfltcc_state->af, 0, sizeof(dfltcc_state->af)); |
||||
+ /* Convert the window from the hardware to the software format */ |
||||
+ rotate(state->window, state->window + param->ho, state->window + HB_SIZE); |
||||
+ state->whave = state->wnext = MIN(param->hl, state->wsize); |
||||
return 0; |
||||
} |
||||
|
||||
@@ -830,9 +866,9 @@ voidpf ZLIB_INTERNAL dfltcc_alloc_window(strm, items, size) |
||||
voidpf p, w; |
||||
|
||||
/* To simplify freeing, we store the pointer to the allocated buffer right |
||||
- * before the window. |
||||
+ * before the window. Note that DFLTCC always uses HB_SIZE bytes. |
||||
*/ |
||||
- p = ZALLOC(strm, sizeof(voidpf) + items * size + PAGE_ALIGN, |
||||
+ p = ZALLOC(strm, sizeof(voidpf) + MAX(items * size, HB_SIZE) + PAGE_ALIGN, |
||||
sizeof(unsigned char)); |
||||
if (p == NULL) |
||||
return NULL; |
||||
@@ -841,6 +877,14 @@ voidpf ZLIB_INTERNAL dfltcc_alloc_window(strm, items, size) |
||||
return w; |
||||
} |
||||
|
||||
+void ZLIB_INTERNAL dfltcc_copy_window(dest, src, n) |
||||
+ void *dest; |
||||
+ const void *src; |
||||
+ size_t n; |
||||
+{ |
||||
+ memcpy(dest, src, MAX(n, HB_SIZE)); |
||||
+} |
||||
+ |
||||
void ZLIB_INTERNAL dfltcc_free_window(strm, w) |
||||
z_streamp strm; |
||||
voidpf w; |
||||
@@ -951,6 +995,24 @@ local void append_history(param, history, buf, count) |
||||
} |
||||
} |
||||
|
||||
+local void get_history OF((struct dfltcc_param_v0 FAR *param, |
||||
+ const Bytef *history, |
||||
+ Bytef *buf)); |
||||
+local void get_history(param, history, buf) |
||||
+ struct dfltcc_param_v0 FAR *param; |
||||
+ const Bytef *history; |
||||
+ Bytef *buf; |
||||
+{ |
||||
+ if (param->ho + param->hl <= HB_SIZE) |
||||
+ /* Circular history buffer does not wrap - copy one chunk */ |
||||
+ memcpy(buf, history + param->ho, param->hl); |
||||
+ else { |
||||
+ /* Circular history buffer wraps - copy two chunks */ |
||||
+ memcpy(buf, history + param->ho, HB_SIZE - param->ho); |
||||
+ memcpy(buf + HB_SIZE - param->ho, history, param->ho + param->hl - HB_SIZE); |
||||
+ } |
||||
+} |
||||
+ |
||||
int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(strm, dictionary, dict_length) |
||||
z_streamp strm; |
||||
const Bytef *dictionary; |
||||
@@ -975,20 +1037,43 @@ int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(strm, dictionary, dict_length) |
||||
struct dfltcc_state FAR *dfltcc_state = GET_DFLTCC_STATE(state); |
||||
struct dfltcc_param_v0 FAR *param = &dfltcc_state->param; |
||||
|
||||
- if (dictionary) { |
||||
- if (param->ho + param->hl <= HB_SIZE) |
||||
- /* Circular history buffer does not wrap - copy one chunk */ |
||||
- zmemcpy(dictionary, state->window + param->ho, param->hl); |
||||
- else { |
||||
- /* Circular history buffer wraps - copy two chunks */ |
||||
- zmemcpy(dictionary, |
||||
- state->window + param->ho, |
||||
- HB_SIZE - param->ho); |
||||
- zmemcpy(dictionary + HB_SIZE - param->ho, |
||||
- state->window, |
||||
- param->ho + param->hl - HB_SIZE); |
||||
- } |
||||
+ if (dictionary) |
||||
+ get_history(param, state->window, dictionary); |
||||
+ if (dict_length) |
||||
+ *dict_length = param->hl; |
||||
+ return Z_OK; |
||||
+} |
||||
+ |
||||
+int ZLIB_INTERNAL dfltcc_inflate_set_dictionary(strm, dictionary, dict_length) |
||||
+ z_streamp strm; |
||||
+ const Bytef *dictionary; |
||||
+ uInt dict_length; |
||||
+{ |
||||
+ struct inflate_state *state = (struct inflate_state *)strm->state; |
||||
+ struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); |
||||
+ struct dfltcc_param_v0 *param = &dfltcc_state->param; |
||||
+ |
||||
+ if (inflate_ensure_window(state)) { |
||||
+ state->mode = MEM; |
||||
+ return Z_MEM_ERROR; |
||||
} |
||||
+ |
||||
+ append_history(param, state->window, dictionary, dict_length); |
||||
+ state->havedict = 1; |
||||
+ return Z_OK; |
||||
+} |
||||
+ |
||||
+int ZLIB_INTERNAL dfltcc_inflate_get_dictionary(strm, dictionary, dict_length) |
||||
+ z_streamp strm; |
||||
+ Bytef *dictionary; |
||||
+ uInt *dict_length; |
||||
+{ |
||||
+ struct inflate_state *state = (struct inflate_state *)strm->state; |
||||
+ struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); |
||||
+ struct dfltcc_param_v0 *param = &dfltcc_state->param; |
||||
+ |
||||
+ if (dictionary && state->window) |
||||
+ get_history(param, state->window, dictionary); |
||||
if (dict_length) |
||||
*dict_length = param->hl; |
||||
return Z_OK; |
||||
--- a/contrib/s390/dfltcc.h |
||||
+++ b/contrib/s390/dfltcc.h |
||||
@@ -11,6 +11,8 @@ void ZLIB_INTERNAL dfltcc_copy_state OF((voidpf dst, const voidpf src, |
||||
void ZLIB_INTERNAL dfltcc_reset OF((z_streamp strm, uInt size)); |
||||
voidpf ZLIB_INTERNAL dfltcc_alloc_window OF((z_streamp strm, uInt items, |
||||
uInt size)); |
||||
+void ZLIB_INTERNAL dfltcc_copy_window OF((void *dest, const void *src, |
||||
+ size_t n)); |
||||
void ZLIB_INTERNAL dfltcc_free_window OF((z_streamp strm, voidpf w)); |
||||
#define DFLTCC_BLOCK_HEADER_BITS 3 |
||||
#define DFLTCC_HLITS_COUNT_BITS 5 |
||||
@@ -44,11 +46,18 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate OF((z_streamp strm, |
||||
int flush, int *ret)); |
||||
int ZLIB_INTERNAL dfltcc_was_inflate_used OF((z_streamp strm)); |
||||
int ZLIB_INTERNAL dfltcc_inflate_disable OF((z_streamp strm)); |
||||
+int ZLIB_INTERNAL dfltcc_inflate_set_dictionary OF((z_streamp strm, |
||||
+ const Bytef *dictionary, |
||||
+ uInt dict_length)); |
||||
+int ZLIB_INTERNAL dfltcc_inflate_get_dictionary OF((z_streamp strm, |
||||
+ Bytef *dictionary, |
||||
+ uInt* dict_length)); |
||||
|
||||
#define ZALLOC_STATE dfltcc_alloc_state |
||||
#define ZFREE_STATE ZFREE |
||||
#define ZCOPY_STATE dfltcc_copy_state |
||||
#define ZALLOC_WINDOW dfltcc_alloc_window |
||||
+#define ZCOPY_WINDOW dfltcc_copy_window |
||||
#define ZFREE_WINDOW dfltcc_free_window |
||||
#define TRY_FREE_WINDOW dfltcc_free_window |
||||
#define INFLATE_RESET_KEEP_HOOK(strm) \ |
||||
@@ -77,5 +86,15 @@ int ZLIB_INTERNAL dfltcc_inflate_disable OF((z_streamp strm)); |
||||
do { \ |
||||
if (dfltcc_was_inflate_used((strm))) return Z_STREAM_ERROR; \ |
||||
} while (0) |
||||
+#define INFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) \ |
||||
+ do { \ |
||||
+ if (dfltcc_can_inflate(strm)) \ |
||||
+ return dfltcc_inflate_set_dictionary(strm, dict, dict_len); \ |
||||
+ } while (0) |
||||
+#define INFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) \ |
||||
+ do { \ |
||||
+ if (dfltcc_can_inflate(strm)) \ |
||||
+ return dfltcc_inflate_get_dictionary(strm, dict, dict_len); \ |
||||
+ } while (0) |
||||
|
||||
#endif |
||||
\ No newline at end of file |
||||
diff --git a/inflate.c b/inflate.c |
||||
index 3750152..a0e2169 100644 |
||||
--- a/inflate.c |
||||
+++ b/inflate.c |
||||
@@ -93,6 +93,7 @@ |
||||
#define ZFREE_STATE ZFREE |
||||
#define ZCOPY_STATE zmemcpy |
||||
#define ZALLOC_WINDOW ZALLOC |
||||
+#define ZCOPY_WINDOW zmemcpy |
||||
#define ZFREE_WINDOW ZFREE |
||||
#define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0) |
||||
#define INFLATE_PRIME_HOOK(strm, bits, value) do {} while (0) |
||||
@@ -101,6 +102,8 @@ |
||||
#define INFLATE_NEED_UPDATEWINDOW(strm) 1 |
||||
#define INFLATE_MARK_HOOK(strm) do {} while (0) |
||||
#define INFLATE_SYNC_POINT_HOOK(strm) do {} while (0) |
||||
+#define INFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
||||
+#define INFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
||||
#endif |
||||
|
||||
#ifdef MAKEFIXED |
||||
@@ -1330,6 +1333,8 @@ uInt *dictLength; |
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
||||
state = (struct inflate_state FAR *)strm->state; |
||||
|
||||
+ INFLATE_GET_DICTIONARY_HOOK(strm, dictionary, dictLength); |
||||
+ |
||||
/* copy dictionary */ |
||||
if (state->whave && dictionary != Z_NULL) { |
||||
zmemcpy(dictionary, state->window + state->wnext, |
||||
@@ -1365,6 +1370,8 @@ uInt dictLength; |
||||
return Z_DATA_ERROR; |
||||
} |
||||
|
||||
+ INFLATE_SET_DICTIONARY_HOOK(strm, dictionary, dictLength); |
||||
+ |
||||
/* copy dictionary to window using updatewindow(), which will amend the |
||||
existing dictionary if appropriate */ |
||||
ret = updatewindow(strm, dictionary + dictLength, dictLength); |
||||
@@ -1529,8 +1536,7 @@ z_streamp source; |
||||
} |
||||
copy->next = copy->codes + (state->next - state->codes); |
||||
if (window != Z_NULL) { |
||||
- wsize = 1U << state->wbits; |
||||
- zmemcpy(window, state->window, wsize); |
||||
+ ZCOPY_WINDOW(window, state->window, 1U << state->wbits); |
||||
} |
||||
copy->window = window; |
||||
dest->state = (struct internal_state FAR *)copy; |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
From 2d80d3f6b52f9fa454c26c89d2d6a1790e1cecb0 Mon Sep 17 00:00:00 2001 |
||||
From: Mark Adler <madler@alumni.caltech.edu> |
||||
Date: Sat, 21 Jan 2017 01:50:26 -0800 |
||||
Subject: [PATCH] Limit hash table inserts after switch from stored deflate. |
||||
|
||||
This limits hash table inserts to the available data in the window |
||||
and to the sliding window size in deflate_stored(). The hash table |
||||
inserts are deferred until deflateParams() switches to a non-zero |
||||
compression level. |
||||
--- |
||||
deflate.c | 10 +++++++++- |
||||
1 file changed, 9 insertions(+), 1 deletion(-) |
||||
|
||||
diff --git a/deflate.c b/deflate.c |
||||
index 20bda4f..d368b25 100644 |
||||
--- a/deflate.c |
||||
+++ b/deflate.c |
||||
@@ -1513,6 +1513,8 @@ local void fill_window(s) |
||||
s->match_start -= wsize; |
||||
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ |
||||
s->block_start -= (long) wsize; |
||||
+ if (s->insert > s->strstart) |
||||
+ s->insert = s->strstart; |
||||
slide_hash(s); |
||||
more += wsize; |
||||
} |
||||
@@ -1742,6 +1744,7 @@ local block_state deflate_stored(s, flush) |
||||
s->matches = 2; /* clear hash */ |
||||
zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); |
||||
s->strstart = s->w_size; |
||||
+ s->insert = s->strstart; |
||||
} |
||||
else { |
||||
if (s->window_size - s->strstart <= used) { |
||||
@@ -1750,12 +1753,14 @@ local block_state deflate_stored(s, flush) |
||||
zmemcpy(s->window, s->window + s->w_size, s->strstart); |
||||
if (s->matches < 2) |
||||
s->matches++; /* add a pending slide_hash() */ |
||||
+ if (s->insert > s->strstart) |
||||
+ s->insert = s->strstart; |
||||
} |
||||
zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); |
||||
s->strstart += used; |
||||
+ s->insert += MIN(used, s->w_size - s->insert); |
||||
} |
||||
s->block_start = s->strstart; |
||||
- s->insert += MIN(used, s->w_size - s->insert); |
||||
} |
||||
if (s->high_water < s->strstart) |
||||
s->high_water = s->strstart; |
||||
@@ -1779,12 +1784,15 @@ local block_state deflate_stored(s, flush) |
||||
if (s->matches < 2) |
||||
s->matches++; /* add a pending slide_hash() */ |
||||
have += s->w_size; /* more space now */ |
||||
+ if (s->insert > s->strstart) |
||||
+ s->insert = s->strstart; |
||||
} |
||||
if (have > s->strm->avail_in) |
||||
have = s->strm->avail_in; |
||||
if (have) { |
||||
read_buf(s->strm, s->window + s->strstart, have); |
||||
s->strstart += have; |
||||
+ s->insert += MIN(have, s->w_size - s->insert); |
||||
} |
||||
if (s->high_water < s->strstart) |
||||
s->high_water = s->strstart; |
||||
-- |
||||
2.39.1 |
||||
|
@ -0,0 +1,282 @@
@@ -0,0 +1,282 @@
|
||||
From 14730a26e830eb2b09d1f7097910616f23c1476e Mon Sep 17 00:00:00 2001 |
||||
From: Ilya Leoshkevich <iii@linux.ibm.com> |
||||
Date: Thu, 2 Feb 2023 19:40:32 +0100 |
||||
Subject: [PATCH] 0001-PATCH-Preparation-for-Power-optimizations.patch |
||||
|
||||
--- |
||||
CMakeLists.txt | 67 ++++++++++++++++++++++++++++++++++++++++++ |
||||
configure | 66 +++++++++++++++++++++++++++++++++++++++++ |
||||
contrib/README.contrib | 8 +++++ |
||||
contrib/gcc/zifunc.h | 60 +++++++++++++++++++++++++++++++++++++ |
||||
contrib/power/power.h | 4 +++ |
||||
5 files changed, 205 insertions(+) |
||||
create mode 100644 contrib/gcc/zifunc.h |
||||
create mode 100644 contrib/power/power.h |
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt |
||||
index 0fe939d..e762023 100644 |
||||
--- a/CMakeLists.txt |
||||
+++ b/CMakeLists.txt |
||||
@@ -7,6 +7,7 @@ set(VERSION "1.2.11") |
||||
|
||||
option(ASM686 "Enable building i686 assembly implementation") |
||||
option(AMD64 "Enable building amd64 assembly implementation") |
||||
+option(POWER "Enable building power implementation") |
||||
|
||||
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
||||
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
||||
@@ -140,6 +141,72 @@ if(CMAKE_COMPILER_IS_GNUCC) |
||||
add_definitions(-DASMV) |
||||
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) |
||||
endif() |
||||
+ |
||||
+ # test to see if we can use a GNU indirect function to detect and load optimized code at runtime |
||||
+ CHECK_C_SOURCE_COMPILES(" |
||||
+ static int test_ifunc_native(void) |
||||
+ { |
||||
+ return 1; |
||||
+ } |
||||
+ static int (*(check_ifunc_native(void)))(void) |
||||
+ { |
||||
+ return test_ifunc_native; |
||||
+ } |
||||
+ int test_ifunc(void) __attribute__ ((ifunc (\"check_ifunc_native\"))); |
||||
+ int main(void) |
||||
+ { |
||||
+ return 0; |
||||
+ } |
||||
+ " HAS_C_ATTR_IFUNC) |
||||
+ |
||||
+ if(HAS_C_ATTR_IFUNC) |
||||
+ add_definitions(-DHAVE_IFUNC) |
||||
+ set(ZLIB_PRIVATE_HDRS ${ZLIB_PRIVATE_HDRS} contrib/gcc/zifunc.h) |
||||
+ endif() |
||||
+ |
||||
+ if(POWER) |
||||
+ # Test to see if we can use the optimizations for Power |
||||
+ CHECK_C_SOURCE_COMPILES(" |
||||
+ #ifndef _ARCH_PPC |
||||
+ #error \"Target is not Power\" |
||||
+ #endif |
||||
+ #ifndef __BUILTIN_CPU_SUPPORTS__ |
||||
+ #error \"Target doesn't support __builtin_cpu_supports()\" |
||||
+ #endif |
||||
+ int main() { return 0; } |
||||
+ " HAS_POWER_SUPPORT) |
||||
+ |
||||
+ if(HAS_POWER_SUPPORT AND HAS_C_ATTR_IFUNC) |
||||
+ add_definitions(-DZ_POWER_OPT) |
||||
+ |
||||
+ set(CMAKE_REQUIRED_FLAGS -mcpu=power8) |
||||
+ CHECK_C_SOURCE_COMPILES("int main(void){return 0;}" POWER8) |
||||
+ |
||||
+ if(POWER8) |
||||
+ add_definitions(-DZ_POWER8) |
||||
+ set(ZLIB_POWER8 ) |
||||
+ |
||||
+ set_source_files_properties( |
||||
+ ${ZLIB_POWER8} |
||||
+ PROPERTIES COMPILE_FLAGS -mcpu=power8) |
||||
+ endif() |
||||
+ |
||||
+ set(CMAKE_REQUIRED_FLAGS -mcpu=power9) |
||||
+ CHECK_C_SOURCE_COMPILES("int main(void){return 0;}" POWER9) |
||||
+ |
||||
+ if(POWER9) |
||||
+ add_definitions(-DZ_POWER9) |
||||
+ set(ZLIB_POWER9 ) |
||||
+ |
||||
+ set_source_files_properties( |
||||
+ ${ZLIB_POWER9} |
||||
+ PROPERTIES COMPILE_FLAGS -mcpu=power9) |
||||
+ endif() |
||||
+ |
||||
+ set(ZLIB_PRIVATE_HDRS ${ZLIB_PRIVATE_HDRS} contrib/power/power.h) |
||||
+ set(ZLIB_SRCS ${ZLIB_SRCS} ${ZLIB_POWER8} ${ZLIB_POWER9}) |
||||
+ endif() |
||||
+ endif() |
||||
endif() |
||||
|
||||
if(MSVC) |
||||
diff --git a/configure b/configure |
||||
index d026b35..0538d58 100755 |
||||
--- a/configure |
||||
+++ b/configure |
||||
@@ -846,6 +846,72 @@ else |
||||
echo "Checking for sys/sdt.h ... No." | tee -a configure.log |
||||
fi |
||||
|
||||
+# test to see if we can use a gnu indirection function to detect and load optimized code at runtime |
||||
+echo >> configure.log |
||||
+cat > $test.c <<EOF |
||||
+static int test_ifunc_native(void) |
||||
+{ |
||||
+ return 1; |
||||
+} |
||||
+ |
||||
+static int (*(check_ifunc_native(void)))(void) |
||||
+{ |
||||
+ return test_ifunc_native; |
||||
+} |
||||
+ |
||||
+int test_ifunc(void) __attribute__ ((ifunc ("check_ifunc_native"))); |
||||
+EOF |
||||
+ |
||||
+if tryboth $CC -c $CFLAGS $test.c; then |
||||
+ SFLAGS="${SFLAGS} -DHAVE_IFUNC" |
||||
+ CFLAGS="${CFLAGS} -DHAVE_IFUNC" |
||||
+ echo "Checking for attribute(ifunc) support... Yes." | tee -a configure.log |
||||
+else |
||||
+ echo "Checking for attribute(ifunc) support... No." | tee -a configure.log |
||||
+fi |
||||
+ |
||||
+# Test to see if we can use the optimizations for Power |
||||
+echo >> configure.log |
||||
+cat > $test.c <<EOF |
||||
+#ifndef _ARCH_PPC |
||||
+ #error "Target is not Power" |
||||
+#endif |
||||
+#ifndef HAVE_IFUNC |
||||
+ #error "Target doesn't support ifunc" |
||||
+#endif |
||||
+#ifndef __BUILTIN_CPU_SUPPORTS__ |
||||
+ #error "Target doesn't support __builtin_cpu_supports()" |
||||
+#endif |
||||
+EOF |
||||
+ |
||||
+if tryboth $CC -c $CFLAGS $test.c; then |
||||
+ echo "int main(void){return 0;}" > $test.c |
||||
+ |
||||
+ if tryboth $CC -c $CFLAGS -mcpu=power8 $test.c; then |
||||
+ POWER8="-DZ_POWER8" |
||||
+ PIC_OBJC="${PIC_OBJC}" |
||||
+ OBJC="${OBJC}" |
||||
+ echo "Checking for -mcpu=power8 support... Yes." | tee -a configure.log |
||||
+ else |
||||
+ echo "Checking for -mcpu=power8 support... No." | tee -a configure.log |
||||
+ fi |
||||
+ |
||||
+ if tryboth $CC -c $CFLAGS -mcpu=power9 $test.c; then |
||||
+ POWER9="-DZ_POWER9" |
||||
+ PIC_OBJC="${PIC_OBJC}" |
||||
+ OBJC="${OBJC}" |
||||
+ echo "Checking for -mcpu=power9 support... Yes." | tee -a configure.log |
||||
+ else |
||||
+ echo "Checking for -mcpu=power9 support... No." | tee -a configure.log |
||||
+ fi |
||||
+ |
||||
+ SFLAGS="${SFLAGS} ${POWER8} ${POWER9} -DZ_POWER_OPT" |
||||
+ CFLAGS="${CFLAGS} ${POWER8} ${POWER9} -DZ_POWER_OPT" |
||||
+ echo "Checking for Power optimizations support... Yes." | tee -a configure.log |
||||
+else |
||||
+ echo "Checking for Power optimizations support... No." | tee -a configure.log |
||||
+fi |
||||
+ |
||||
# show the results in the log |
||||
echo >> configure.log |
||||
echo ALL = $ALL >> configure.log |
||||
diff --git a/contrib/README.contrib b/contrib/README.contrib |
||||
index b4d3b18..2a53f90 100644 |
||||
--- a/contrib/README.contrib |
||||
+++ b/contrib/README.contrib |
||||
@@ -19,6 +19,10 @@ asm686/ by Brian Raiter <breadbox@muppetlabs.com> |
||||
blast/ by Mark Adler <madler@alumni.caltech.edu> |
||||
Decompressor for output of PKWare Data Compression Library (DCL) |
||||
|
||||
+gcc/ by Matheus Castanho <msc@linux.ibm.com> |
||||
+ and Rogerio Alves <rcardoso@linux.ibm.com> |
||||
+ Optimization helpers using GCC-specific extensions |
||||
+ |
||||
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro> |
||||
Support for Delphi and C++ Builder |
||||
|
||||
@@ -63,6 +67,10 @@ minizip/ by Gilles Vollant <info@winimage.com> |
||||
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al. |
||||
Support for Pascal |
||||
|
||||
+power/ by Matheus Castanho <msc@linux.ibm.com> |
||||
+ and Rogerio Alves <rcardoso@linux.ibm.com> |
||||
+ Optimized functions for Power processors |
||||
+ |
||||
puff/ by Mark Adler <madler@alumni.caltech.edu> |
||||
Small, low memory usage inflate. Also serves to provide an |
||||
unambiguous description of the deflate format. |
||||
diff --git a/contrib/gcc/zifunc.h b/contrib/gcc/zifunc.h |
||||
new file mode 100644 |
||||
index 0000000..daf4fe4 |
||||
--- /dev/null |
||||
+++ b/contrib/gcc/zifunc.h |
||||
@@ -0,0 +1,60 @@ |
||||
+/* Copyright (C) 2019 Matheus Castanho <msc@linux.ibm.com>, IBM |
||||
+ * 2019 Rogerio Alves <rogerio.alves@ibm.com>, IBM |
||||
+ * For conditions of distribution and use, see copyright notice in zlib.h |
||||
+ */ |
||||
+ |
||||
+#ifndef Z_IFUNC_H_ |
||||
+#define Z_IFUNC_H_ |
||||
+ |
||||
+/* Helpers for arch optimizations */ |
||||
+ |
||||
+#define Z_IFUNC(fname) \ |
||||
+ typeof(fname) fname __attribute__ ((ifunc (#fname "_resolver"))); \ |
||||
+ local typeof(fname) *fname##_resolver(void) |
||||
+/* This is a helper macro to declare a resolver for an indirect function |
||||
+ * (ifunc). Let's say you have function |
||||
+ * |
||||
+ * int foo (int a); |
||||
+ * |
||||
+ * for which you want to provide different implementations, for example: |
||||
+ * |
||||
+ * int foo_clever (int a) { |
||||
+ * ... clever things ... |
||||
+ * } |
||||
+ * |
||||
+ * int foo_smart (int a) { |
||||
+ * ... smart things ... |
||||
+ * } |
||||
+ * |
||||
+ * You will have to declare foo() as an indirect function and also provide a |
||||
+ * resolver for it, to choose between foo_clever() and foo_smart() based on |
||||
+ * some criteria you define (e.g. processor features). |
||||
+ * |
||||
+ * Since most likely foo() has a default implementation somewhere in zlib, you |
||||
+ * may have to rename it so the 'foo' symbol can be used by the ifunc without |
||||
+ * conflicts. |
||||
+ * |
||||
+ * #define foo foo_default |
||||
+ * int foo (int a) { |
||||
+ * ... |
||||
+ * } |
||||
+ * #undef foo |
||||
+ * |
||||
+ * Now you just have to provide a resolver function to choose which function |
||||
+ * should be used (decided at runtime on the first call to foo()): |
||||
+ * |
||||
+ * Z_IFUNC(foo) { |
||||
+ * if (... some condition ...) |
||||
+ * return foo_clever; |
||||
+ * |
||||
+ * if (... other condition ...) |
||||
+ * return foo_smart; |
||||
+ * |
||||
+ * return foo_default; |
||||
+ * } |
||||
+ * |
||||
+ * All calls to foo() throughout the code can remain untouched, all the magic |
||||
+ * will be done by the linker using the resolver function. |
||||
+ */ |
||||
+ |
||||
+#endif /* Z_IFUNC_H_ */ |
||||
diff --git a/contrib/power/power.h b/contrib/power/power.h |
||||
new file mode 100644 |
||||
index 0000000..b42c7d6 |
||||
--- /dev/null |
||||
+++ b/contrib/power/power.h |
||||
@@ -0,0 +1,4 @@ |
||||
+/* Copyright (C) 2019 Matheus Castanho <msc@linux.ibm.com>, IBM |
||||
+ * 2019 Rogerio Alves <rogerio.alves@ibm.com>, IBM |
||||
+ * For conditions of distribution and use, see copyright notice in zlib.h |
||||
+ */ |
||||
-- |
||||
2.39.1 |
||||
|
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001 |
||||
From: Mark Adler <fork@madler.net> |
||||
Date: Sat, 30 Jul 2022 15:51:11 -0700 |
||||
Subject: [PATCH] Fix a bug when getting a gzip header extra field with |
||||
inflate(). |
||||
|
||||
If the extra field was larger than the space the user provided with |
||||
inflateGetHeader(), and if multiple calls of inflate() delivered |
||||
the extra header data, then there could be a buffer overflow of the |
||||
provided space. This commit assures that provided space is not |
||||
exceeded. |
||||
--- |
||||
inflate.c | 5 +++-- |
||||
1 file changed, 3 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/inflate.c b/inflate.c |
||||
index 7be8c63..7a72897 100644 |
||||
--- a/inflate.c |
||||
+++ b/inflate.c |
||||
@@ -763,9 +763,10 @@ int flush; |
||||
copy = state->length; |
||||
if (copy > have) copy = have; |
||||
if (copy) { |
||||
+ len = state->head->extra_len - state->length; |
||||
if (state->head != Z_NULL && |
||||
- state->head->extra != Z_NULL) { |
||||
- len = state->head->extra_len - state->length; |
||||
+ state->head->extra != Z_NULL && |
||||
+ len < state->head->extra_max) { |
||||
zmemcpy(state->head->extra + len, next, |
||||
len + copy > state->head->extra_max ? |
||||
state->head->extra_max - len : copy); |
||||
-- |
||||
2.35.3 |
||||
|
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001 |
||||
From: Mark Adler <fork@madler.net> |
||||
Date: Mon, 8 Aug 2022 10:50:09 -0700 |
||||
Subject: [PATCH] Fix extra field processing bug that dereferences NULL |
||||
state->head. |
||||
|
||||
The recent commit to fix a gzip header extra field processing bug |
||||
introduced the new bug fixed here. |
||||
--- |
||||
inflate.c | 4 ++-- |
||||
1 file changed, 2 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/inflate.c b/inflate.c |
||||
index 7a72897..2a3c4fe 100644 |
||||
--- a/inflate.c |
||||
+++ b/inflate.c |
||||
@@ -763,10 +763,10 @@ int flush; |
||||
copy = state->length; |
||||
if (copy > have) copy = have; |
||||
if (copy) { |
||||
- len = state->head->extra_len - state->length; |
||||
if (state->head != Z_NULL && |
||||
state->head->extra != Z_NULL && |
||||
- len < state->head->extra_max) { |
||||
+ (len = state->head->extra_len - state->length) < |
||||
+ state->head->extra_max) { |
||||
zmemcpy(state->head->extra + len, next, |
||||
len + copy > state->head->extra_max ? |
||||
state->head->extra_max - len : copy); |
||||
-- |
||||
2.35.3 |
||||
|
Loading…
Reference in new issue