35811d
From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001
35811d
From: Mark Adler <fork@madler.net>
35811d
Date: Mon, 8 Aug 2022 10:50:09 -0700
35811d
Subject: [PATCH] Fix extra field processing bug that dereferences NULL
35811d
 state->head.
35811d
35811d
The recent commit to fix a gzip header extra field processing bug
35811d
introduced the new bug fixed here.
35811d
---
35811d
 inflate.c | 4 ++--
35811d
 1 file changed, 2 insertions(+), 2 deletions(-)
35811d
35811d
diff --git a/inflate.c b/inflate.c
35811d
index 7a72897..2a3c4fe 100644
35811d
--- a/inflate.c
35811d
+++ b/inflate.c
35811d
@@ -763,10 +763,10 @@ int flush;
35811d
                 copy = state->length;
35811d
                 if (copy > have) copy = have;
35811d
                 if (copy) {
35811d
-                    len = state->head->extra_len - state->length;
35811d
                     if (state->head != Z_NULL &&
35811d
                         state->head->extra != Z_NULL &&
35811d
-                        len < state->head->extra_max) {
35811d
+                        (len = state->head->extra_len - state->length) <
35811d
+                            state->head->extra_max) {
35811d
                         zmemcpy(state->head->extra + len, next,
35811d
                                 len + copy > state->head->extra_max ?
35811d
                                 state->head->extra_max - len : copy);
35811d
-- 
35811d
2.35.3
35811d