summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-09-14 11:10:57 +0200
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-10-28 21:17:01 +0200
commit7b69d50645ceeb59d3fd75e698c82efcc5386a92 (patch)
tree28e22672055e990d21fa2ffcb7d3dc6759c592ba
parentlibxml2: upgrade to release 2.10.2 (diff)
downloadcore-7b69d50645ceeb59d3fd75e698c82efcc5386a92.tar.gz
core-7b69d50645ceeb59d3fd75e698c82efcc5386a92.zip
zlib: add patch for CVE-2022-37434
Change-Id: If09c419ba00fc9be021249e4d4da27d1650b9080 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139913 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 521e920dda79f44a0ad637b6062f3dcb574f884b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139849 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> (cherry picked from commit 832e2a266005d8ef5f9bcc7f51b545d5dc4ce165)
-rw-r--r--external/zlib/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d.patch29
-rw-r--r--external/zlib/UnpackedTarball_zlib.mk7
-rw-r--r--external/zlib/eff308af425b67093bab25f80f1ae950166bece1.patch32
3 files changed, 67 insertions, 1 deletions
diff --git a/external/zlib/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d.patch b/external/zlib/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d.patch
new file mode 100644
index 000000000000..c5c95a92b28a
--- /dev/null
+++ b/external/zlib/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d.patch
@@ -0,0 +1,29 @@
+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 7a7289749..2a3c4fe98 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);
diff --git a/external/zlib/UnpackedTarball_zlib.mk b/external/zlib/UnpackedTarball_zlib.mk
index dd9fc1c31445..10ee74b9568a 100644
--- a/external/zlib/UnpackedTarball_zlib.mk
+++ b/external/zlib/UnpackedTarball_zlib.mk
@@ -16,6 +16,11 @@ $(eval $(call gb_UnpackedTarball_set_post_action,zlib,\
cp $(addsuffix .c,adler32 compress crc32 deflate inffast inflate inftrees trees zutil) x64 \
))
-$(eval $(call gb_UnpackedTarball_set_patchlevel,zlib,0))
+$(eval $(call gb_UnpackedTarball_set_patchlevel,zlib,1))
+
+$(eval $(call gb_UnpackedTarball_add_patches,zlib,\
+ external/zlib/eff308af425b67093bab25f80f1ae950166bece1.patch \
+ external/zlib/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d.patch \
+))
# vim: set noet sw=4 ts=4:
diff --git a/external/zlib/eff308af425b67093bab25f80f1ae950166bece1.patch b/external/zlib/eff308af425b67093bab25f80f1ae950166bece1.patch
new file mode 100644
index 000000000000..dc84d3a1d385
--- /dev/null
+++ b/external/zlib/eff308af425b67093bab25f80f1ae950166bece1.patch
@@ -0,0 +1,32 @@
+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 7be8c6366..7a7289749 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);