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