adenilson / rpms / zlib

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