blob: a0978c5f953fe778b6598731e9131aedce2b7c0a [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001
2From: Mark Adler <fork@madler.net>
3Date: Mon, 8 Aug 2022 10:50:09 -0700
4Subject: [PATCH] Fix extra field processing bug that dereferences NULL
5 state->head.
6
7The recent commit to fix a gzip header extra field processing bug
8introduced the new bug fixed here.
9
10CVE: CVE-2022-37434
11Upstream-Status: Backport [https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 inflate.c | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/inflate.c b/inflate.c
18index 7a72897..2a3c4fe 100644
19--- a/inflate.c
20+++ b/inflate.c
21@@ -763,10 +763,10 @@ int flush;
22 copy = state->length;
23 if (copy > have) copy = have;
24 if (copy) {
25- len = state->head->extra_len - state->length;
26 if (state->head != Z_NULL &&
27 state->head->extra != Z_NULL &&
28- len < state->head->extra_max) {
29+ (len = state->head->extra_len - state->length) <
30+ state->head->extra_max) {
31 zmemcpy(state->head->extra + len, next,
32 len + copy > state->head->extra_max ?
33 state->head->extra_max - len : copy);
34--
352.37.2
36