mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] zlib: Fix CVE-2022-37434.
@ 2022-09-07 10:28 Christian Melki
  2022-09-11  7:10 ` [ptxdist] [APPLIED] " Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Melki @ 2022-09-07 10:28 UTC (permalink / raw)
  To: ptxdist

Severity score of 9.8.
https://nvd.nist.gov/vuln/detail/CVE-2022-37434
Patches taken from zlib develop branch.

https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d
https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1

Signed-off-by: Christian Melki <christian.melki@t2data.com>
---
 ...etting-a-gzip-header-extra-field-wit.patch | 31 +++++++++++++++++++
 ...processing-bug-that-dereferences-NUL.patch | 28 +++++++++++++++++
 patches/zlib-1.2.12/series                    |  4 ++-
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
 create mode 100644 patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch

diff --git a/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch b/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
new file mode 100644
index 000000000..e8b36be46
--- /dev/null
+++ b/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
@@ -0,0 +1,31 @@
+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 7be8c63662a7..7a728974923a 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);
diff --git a/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch b/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
new file mode 100644
index 000000000..381c52128
--- /dev/null
+++ b/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
@@ -0,0 +1,28 @@
+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 7a728974923a..2a3c4fe98464 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/patches/zlib-1.2.12/series b/patches/zlib-1.2.12/series
index ac92b3ba7..5287c5835 100644
--- a/patches/zlib-1.2.12/series
+++ b/patches/zlib-1.2.12/series
@@ -1,4 +1,6 @@
 # generated by git-ptx-patches
 #tag:base --start-number 1
 0001-Fix-configure-issue-that-discarded-provided-CC-defin.patch
-# 5dfc5088b94416c3eb59b1a207bdec70  - git-ptx-patches magic
+0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
+0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
+# cd27facc69e3374f1354a2aca57309ec  - git-ptx-patches magic
-- 
2.34.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [APPLIED] zlib: Fix CVE-2022-37434.
  2022-09-07 10:28 [ptxdist] [PATCH] zlib: Fix CVE-2022-37434 Christian Melki
@ 2022-09-11  7:10 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2022-09-11  7:10 UTC (permalink / raw)
  To: ptxdist; +Cc: Christian Melki

Thanks, applied as 90f7f51f26313d27d1e0021f623c8746c12d109b.

Michael

[sent from post-receive hook]

On Sun, 11 Sep 2022 09:10:18 +0200, Christian Melki <christian.melki@t2data.com> wrote:
> Severity score of 9.8.
> https://nvd.nist.gov/vuln/detail/CVE-2022-37434
> Patches taken from zlib develop branch.
> 
> https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d
> https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1
> 
> Signed-off-by: Christian Melki <christian.melki@t2data.com>
> Message-Id: <20220907102811.628405-1-christian.melki@t2data.com>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch b/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
> new file mode 100644
> index 000000000000..e8b36be46ac3
> --- /dev/null
> +++ b/patches/zlib-1.2.12/0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
> @@ -0,0 +1,31 @@
> +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 7be8c63662a7..7a728974923a 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);
> diff --git a/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch b/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
> new file mode 100644
> index 000000000000..381c5212898c
> --- /dev/null
> +++ b/patches/zlib-1.2.12/0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
> @@ -0,0 +1,28 @@
> +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 7a728974923a..2a3c4fe98464 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/patches/zlib-1.2.12/series b/patches/zlib-1.2.12/series
> index ac92b3ba7f39..5287c5835744 100644
> --- a/patches/zlib-1.2.12/series
> +++ b/patches/zlib-1.2.12/series
> @@ -1,4 +1,6 @@
>  # generated by git-ptx-patches
>  #tag:base --start-number 1
>  0001-Fix-configure-issue-that-discarded-provided-CC-defin.patch
> -# 5dfc5088b94416c3eb59b1a207bdec70  - git-ptx-patches magic
> +0002-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch
> +0003-Fix-extra-field-processing-bug-that-dereferences-NUL.patch
> +# cd27facc69e3374f1354a2aca57309ec  - git-ptx-patches magic



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-11  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 10:28 [ptxdist] [PATCH] zlib: Fix CVE-2022-37434 Christian Melki
2022-09-11  7:10 ` [ptxdist] [APPLIED] " Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox