Fix for the libxml2 and lxml on s390x

Resolves: #2155328
This commit is contained in:
Lukas Javorsky 2023-01-11 11:15:11 +00:00
parent d7912252c7
commit 73adb24ba0
3 changed files with 269 additions and 86 deletions

View File

@ -0,0 +1,30 @@
From e554695638228b846d49657f31eeff0ca4680e8a Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Thu, 15 Dec 2022 09:07:13 -0800
Subject: [PATCH] Fix bug in deflateBound() for level 0 and memLevel 9.
memLevel 9 would cause deflateBound() to assume the use of fixed
blocks, even if the compression level was 0, which forces stored
blocks. That could result in a bound less than the size of the
compressed data. Now level 0 always uses the stored blocks bound.
---
deflate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/deflate.c b/deflate.c
index cd538b8..4a512e1 100644
--- a/deflate.c
+++ b/deflate.c
@@ -752,7 +752,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
/* if not default parameters, return one of the conservative bounds */
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
+ return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
+ wraplen;
/* default settings: return tight bound for that case -- ~0.03% overhead
plus a small constant */
--
2.38.1

View File

@ -1,4 +1,4 @@
From 48c5416a4e21227b8e1aa24fd819d4619a90e1a9 Mon Sep 17 00:00:00 2001
From 113203437eda67261848b14b6c80a33ff7e33d34 Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <iii@linux.ibm.com>
Date: Wed, 18 Jul 2018 13:14:07 +0200
Subject: [PATCH] Add support for IBM Z hardware-accelerated deflate
@ -52,10 +52,11 @@ macros were introduced in order to encapsulate the allocation details.
The same is true for window, for which ZALLOC_WINDOW and
TRY_FREE_WINDOW macros were introduced.
While for inflate software and hardware window formats match, this is
not the case for deflate. Therefore, deflateSetDictionary and
deflateGetDictionary need special handling, which is triggered using the
new DEFLATE_SET_DICTIONARY_HOOK and DEFLATE_GET_DICTIONARY_HOOK macros.
Software and hardware window formats do not match, therefore,
deflateSetDictionary(), deflateGetDictionary(), inflateSetDictionary()
and inflateGetDictionary() need special handling, which is triggered
using DEFLATE_SET_DICTIONARY_HOOK, DEFLATE_GET_DICTIONARY_HOOK,
INFLATE_SET_DICTIONARY_HOOK and INFLATE_GET_DICTIONARY_HOOK macros.
deflateResetKeep() and inflateResetKeep() now update the DFLTCC
parameter block, which is allocated alongside zlib state, using
@ -95,31 +96,31 @@ Since the first call to dfltcc_inflate already needs the window, and it
might be not allocated yet, inflate_ensure_window was factored out of
updatewindow and made ZLIB_INTERNAL.
---
Makefile.in | 8 +
compress.c | 14 +-
configure | 24 +
contrib/README.contrib | 4 +
contrib/s390/README.txt | 17 +
contrib/s390/dfltcc.c | 995 ++++++++++++++++++++++++++++++++++
contrib/s390/dfltcc.h | 81 +++
contrib/s390/dfltcc_deflate.h | 55 ++
deflate.c | 82 ++-
deflate.h | 12 +
gzguts.h | 4 +
inflate.c | 87 ++-
inflate.h | 2 +
test/infcover.c | 4 +-
test/minigzip.c | 4 +
trees.c | 13 +-
zutil.h | 2 +
17 files changed, 1348 insertions(+), 60 deletions(-)
Makefile.in | 8 +
compress.c | 14 +-
configure | 24 +
contrib/README.contrib | 4 +
contrib/s390/README.txt | 17 +
contrib/s390/dfltcc.c | 1089 +++++++++++++++++++++++++++++++++
contrib/s390/dfltcc.h | 100 +++
contrib/s390/dfltcc_deflate.h | 55 ++
deflate.c | 82 ++-
deflate.h | 12 +
gzguts.h | 4 +
inflate.c | 97 ++-
inflate.h | 2 +
test/infcover.c | 4 +-
test/minigzip.c | 4 +
trees.c | 13 +-
zutil.h | 2 +
17 files changed, 1469 insertions(+), 62 deletions(-)
create mode 100644 contrib/s390/README.txt
create mode 100644 contrib/s390/dfltcc.c
create mode 100644 contrib/s390/dfltcc.h
create mode 100644 contrib/s390/dfltcc_deflate.h
diff --git a/Makefile.in b/Makefile.in
index 408954d..a811c10 100644
index 83d8ca4..54c529b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -139,6 +139,14 @@ match.lo: match.S
@ -260,10 +261,10 @@ index 0000000..48be008
+DFLTCC_LEVEL_MASK to 0x7e at run time.
diff --git a/contrib/s390/dfltcc.c b/contrib/s390/dfltcc.c
new file mode 100644
index 0000000..aa0b7a3
index 0000000..b8c20bd
--- /dev/null
+++ b/contrib/s390/dfltcc.c
@@ -0,0 +1,995 @@
@@ -0,0 +1,1089 @@
+/* dfltcc.c - SystemZ DEFLATE CONVERSION CALL support. */
+
+/*
@ -723,7 +724,10 @@ index 0000000..aa0b7a3
+ *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) {
@ -755,7 +759,10 @@ index 0000000..aa0b7a3
+ 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;
@ -806,10 +813,6 @@ index 0000000..aa0b7a3
+ 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);
@ -871,13 +874,12 @@ index 0000000..aa0b7a3
+ }
+
+ /* 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;
+ 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;
+ if (state->wrap & 4)
+ param->cv = state->flags ? ZSWAP32(state->check) : state->check;
+
+ /* Inflate */
+ do {
@ -888,9 +890,9 @@ index 0000000..aa0b7a3
+ 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 (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;
@ -911,11 +913,52 @@ index 0000000..aa0b7a3
+ 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;
@ -927,6 +970,9 @@ index 0000000..aa0b7a3
+ 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;
+}
+
@ -1096,9 +1142,9 @@ index 0000000..aa0b7a3
+ 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;
@ -1107,6 +1153,14 @@ index 0000000..aa0b7a3
+ 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;
@ -1217,6 +1271,24 @@ index 0000000..aa0b7a3
+ }
+}
+
+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;
@ -1241,30 +1313,53 @@ index 0000000..aa0b7a3
+ 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;
+}
diff --git a/contrib/s390/dfltcc.h b/contrib/s390/dfltcc.h
new file mode 100644
index 0000000..da26612
index 0000000..be28b8a
--- /dev/null
+++ b/contrib/s390/dfltcc.h
@@ -0,0 +1,81 @@
@@ -0,0 +1,100 @@
+#ifndef DFLTCC_H
+#define DFLTCC_H
+
@ -1278,6 +1373,8 @@ index 0000000..da26612
+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
@ -1311,11 +1408,18 @@ index 0000000..da26612
+ 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) \
@ -1344,6 +1448,16 @@ index 0000000..da26612
+ 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
diff --git a/contrib/s390/dfltcc_deflate.h b/contrib/s390/dfltcc_deflate.h
@ -1408,7 +1522,7 @@ index 0000000..46acfc5
+
+#endif
diff --git a/deflate.c b/deflate.c
index 4a689db..9fd3bdb 100644
index 4a512e1..ba446d9 100644
--- a/deflate.c
+++ b/deflate.c
@@ -61,15 +61,30 @@ const char deflate_copyright[] =
@ -1552,10 +1666,10 @@ index 4a689db..9fd3bdb 100644
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
+ if (DEFLATE_NEED_CONSERVATIVE_BOUND(strm) ||
+ s->w_bits != 15 || s->hash_bits != 8 + 7)
return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
wraplen;
/* default settings: return tight bound for that case -- ~0.03% overhead
@@ -779,7 +804,7 @@ local void putShortMSB(s, b)
@@ -780,7 +805,7 @@ local void putShortMSB(s, b)
* applications may wish to modify it to avoid allocating a large
* strm->next_out buffer and copying into it. (See also read_buf()).
*/
@ -1564,7 +1678,7 @@ index 4a689db..9fd3bdb 100644
z_streamp strm;
{
unsigned len;
@@ -1051,7 +1076,8 @@ int ZEXPORT deflate(strm, flush)
@@ -1052,7 +1077,8 @@ int ZEXPORT deflate(strm, flush)
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
@ -1574,7 +1688,7 @@ index 4a689db..9fd3bdb 100644
s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
s->strategy == Z_RLE ? deflate_rle(s, flush) :
(*(configuration_table[s->level].func))(s, flush);
@@ -1098,7 +1124,6 @@ int ZEXPORT deflate(strm, flush)
@@ -1099,7 +1125,6 @@ int ZEXPORT deflate(strm, flush)
}
if (flush != Z_FINISH) return Z_OK;
@ -1582,7 +1696,7 @@ index 4a689db..9fd3bdb 100644
/* Write the trailer */
#ifdef GZIP
@@ -1114,7 +1139,7 @@ int ZEXPORT deflate(strm, flush)
@@ -1115,7 +1140,7 @@ int ZEXPORT deflate(strm, flush)
}
else
#endif
@ -1591,7 +1705,7 @@ index 4a689db..9fd3bdb 100644
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
}
@@ -1123,7 +1148,11 @@ int ZEXPORT deflate(strm, flush)
@@ -1124,7 +1149,11 @@ int ZEXPORT deflate(strm, flush)
* to flush the rest.
*/
if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
@ -1604,7 +1718,7 @@ index 4a689db..9fd3bdb 100644
}
/* ========================================================================= */
@@ -1140,9 +1169,9 @@ int ZEXPORT deflateEnd(strm)
@@ -1141,9 +1170,9 @@ int ZEXPORT deflateEnd(strm)
TRY_FREE(strm, strm->state->pending_buf);
TRY_FREE(strm, strm->state->head);
TRY_FREE(strm, strm->state->prev);
@ -1616,7 +1730,7 @@ index 4a689db..9fd3bdb 100644
strm->state = Z_NULL;
return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
@@ -1172,13 +1201,13 @@ int ZEXPORT deflateCopy(dest, source)
@@ -1173,13 +1202,13 @@ int ZEXPORT deflateCopy(dest, source)
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
@ -1633,7 +1747,7 @@ index 4a689db..9fd3bdb 100644
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
@@ -1225,7 +1254,8 @@ local unsigned read_buf(strm, buf, size)
@@ -1226,7 +1255,8 @@ local unsigned read_buf(strm, buf, size)
strm->avail_in -= len;
zmemcpy(buf, strm->next_in, len);
@ -1688,10 +1802,10 @@ index 57faf37..581f2b6 100644
/* gzip modes, also provide a little integrity check on the passed structure */
#define GZ_NONE 0
diff --git a/inflate.c b/inflate.c
index 8acbef4..918dfa7 100644
index 8acbef4..19dc724 100644
--- a/inflate.c
+++ b/inflate.c
@@ -85,6 +85,24 @@
@@ -85,6 +85,27 @@
#include "inflate.h"
#include "inffast.h"
@ -1703,6 +1817,7 @@ index 8acbef4..918dfa7 100644
+#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)
@ -1711,12 +1826,14 @@ index 8acbef4..918dfa7 100644
+#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
# ifndef BUILDFIXED
# define BUILDFIXED
@@ -138,6 +156,7 @@ z_streamp strm;
@@ -138,6 +159,7 @@ z_streamp strm;
state->lencode = state->distcode = state->next = state->codes;
state->sane = 1;
state->back = -1;
@ -1724,7 +1841,7 @@ index 8acbef4..918dfa7 100644
Tracev((stderr, "inflate: reset\n"));
return Z_OK;
}
@@ -185,7 +204,7 @@ int windowBits;
@@ -185,7 +207,7 @@ int windowBits;
if (windowBits && (windowBits < 8 || windowBits > 15))
return Z_STREAM_ERROR;
if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
@ -1733,7 +1850,7 @@ index 8acbef4..918dfa7 100644
state->window = Z_NULL;
}
@@ -224,7 +243,7 @@ int stream_size;
@@ -224,7 +246,7 @@ int stream_size;
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)
@ -1742,7 +1859,7 @@ index 8acbef4..918dfa7 100644
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
@@ -233,7 +252,7 @@ int stream_size;
@@ -233,7 +255,7 @@ int stream_size;
state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
@ -1751,7 +1868,7 @@ index 8acbef4..918dfa7 100644
strm->state = Z_NULL;
}
return ret;
@@ -255,6 +274,7 @@ int value;
@@ -255,6 +277,7 @@ int value;
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@ -1759,7 +1876,7 @@ index 8acbef4..918dfa7 100644
state = (struct inflate_state FAR *)strm->state;
if (bits < 0) {
state->hold = 0;
@@ -382,6 +402,27 @@ void makefixed()
@@ -382,6 +405,27 @@ void makefixed()
}
#endif /* MAKEFIXED */
@ -1787,7 +1904,7 @@ index 8acbef4..918dfa7 100644
/*
Update the window with the last wsize (normally 32K) bytes written before
returning. If window does not exist yet, create it. This is only called
@@ -406,20 +447,7 @@ unsigned copy;
@@ -406,20 +450,7 @@ unsigned copy;
state = (struct inflate_state FAR *)strm->state;
@ -1809,7 +1926,7 @@ index 8acbef4..918dfa7 100644
/* copy state->wsize or less output bytes into the circular window */
if (copy >= state->wsize) {
@@ -863,6 +891,7 @@ int flush;
@@ -863,6 +894,7 @@ int flush;
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
/* fallthrough */
case TYPEDO:
@ -1817,7 +1934,7 @@ index 8acbef4..918dfa7 100644
if (state->last) {
BYTEBITS();
state->mode = CHECK;
@@ -1224,7 +1253,7 @@ int flush;
@@ -1224,7 +1256,7 @@ int flush;
out -= left;
strm->total_out += out;
state->total += out;
@ -1826,7 +1943,7 @@ index 8acbef4..918dfa7 100644
strm->adler = state->check =
UPDATE_CHECK(state->check, put - out, out);
out = left;
@@ -1279,8 +1308,9 @@ int flush;
@@ -1279,8 +1311,9 @@ int flush;
*/
inf_leave:
RESTORE();
@ -1838,7 +1955,7 @@ index 8acbef4..918dfa7 100644
if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
state->mode = MEM;
return Z_MEM_ERROR;
@@ -1290,7 +1320,7 @@ int flush;
@@ -1290,7 +1323,7 @@ int flush;
strm->total_in += in;
strm->total_out += out;
state->total += out;
@ -1847,7 +1964,7 @@ index 8acbef4..918dfa7 100644
strm->adler = state->check =
UPDATE_CHECK(state->check, strm->next_out - out, out);
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
@@ -1308,8 +1338,8 @@ z_streamp strm;
@@ -1308,8 +1341,8 @@ z_streamp strm;
if (inflateStateCheck(strm))
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
@ -1858,7 +1975,25 @@ index 8acbef4..918dfa7 100644
strm->state = Z_NULL;
Tracev((stderr, "inflate: end\n"));
return Z_OK;
@@ -1488,6 +1518,7 @@ z_streamp strm;
@@ -1326,6 +1359,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,
@@ -1361,6 +1396,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);
@@ -1488,6 +1525,7 @@ z_streamp strm;
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@ -1866,7 +2001,7 @@ index 8acbef4..918dfa7 100644
state = (struct inflate_state FAR *)strm->state;
return state->mode == STORED && state->bits == 0;
}
@@ -1508,21 +1539,22 @@ z_streamp source;
@@ -1508,21 +1546,22 @@ z_streamp source;
/* allocate space */
copy = (struct inflate_state FAR *)
@ -1893,7 +2028,17 @@ index 8acbef4..918dfa7 100644
copy->strm = dest;
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
@@ -1579,6 +1611,7 @@ z_streamp strm;
@@ -1531,8 +1570,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;
@@ -1579,6 +1617,7 @@ z_streamp strm;
if (inflateStateCheck(strm))
return -(1L << 16);
@ -2008,5 +2153,5 @@ index 0bc7f4e..75eb4df 100644
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
--
2.37.3
2.38.1

View File

@ -2,7 +2,7 @@
Name: zlib
Version: 1.2.13
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Compression and decompression library
# /contrib/dotzlib/ have Boost license
License: zlib and Boost
@ -13,6 +13,9 @@ Source: https://www.zlib.net/zlib-%{version}.tar.xz
Patch0: zlib-1.2.5-minizip-fixuncrypt.patch
# resolves: #805113
Patch1: zlib-1.2.13-optimized-s390.patch
# Upstream commit: https://github.com/madler/zlib/commit/e554695638228b846d49657f31eeff0ca4680e8a
# This patch is needed for a clean apply of the Patch19
Patch2: zlib-1.2.13-Fix-bug-in-deflateBound.patch
# IBM optimized crc32 for Power 8+ processors
# ref: https://github.com/madler/zlib/pull/750
Patch18: zlib-1.2.13-power-optimizations.patch
@ -82,6 +85,7 @@ developing applications which use minizip.
%prep
%setup -q
%patch0 -p1 -b .fixuncrypt
%patch2 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
@ -169,6 +173,10 @@ find $RPM_BUILD_ROOT -name '*.la' -delete
%changelog
* Tue Jan 10 2023 Lukas Javorsky <ljavorsk@redhat.com> - 1.2.13-2
- Fix for the libxml2 and lxml on s390x
- Resolves #2155328
* Mon Oct 17 2022 Lukas Javorsky <ljavorsk@redhat.com> - 1.2.13-1
- Rebase to version 1.2.13
- Patches 21,24,25 has been upstreamed