1- From b49d2f0b84d424ec7fbf47138bf6acc6b18e1b0d Mon Sep 17 00:00:00 2001
2- From: tabudz <tanb74653@gmail.com >
3- Date: Tue, 18 Feb 2025 11:28:15 +0800
1+ From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001
2+ From: Mark Adler <fork@madler.net >
3+ Date: Sat, 30 Jul 2022 15:51:11 -0700
44Subject: [PATCH] Fix a bug when getting a gzip header extra field with
5- inflate(). If the extra field was larger than the space the user provided
6- with inflateGetHeader(), and if multiple calls of inflate() delivered the
7- extra header data, then there could be a buffer overflow of the provided
8- space. This commit assures that provided space is not exceeded.
5+ inflate().
96
10- Upstream Reference: https://github.com/radareorg/radare2/pull/23969/commits/b49d2f0b84d424ec7fbf47138bf6acc6b18e1b0d
7+ If the extra field was larger than the space the user provided with
8+ inflateGetHeader(), and if multiple calls of inflate() delivered
9+ the extra header data, then there could be a buffer overflow of the
10+ provided space. This commit assures that provided space is not
11+ exceeded.
12+
13+ Upstream Reference : https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1
1114---
1215 inflate.c | 5 +++--
1316 1 file changed, 3 insertions(+), 2 deletions(-)
1417
1518diff --git a/inflate.c b/inflate.c
16- index e9ed74cff3279..2ecfb4876d155 100644
19+ index 7be8c6366..7a7289749 100644
1720--- a/inflate.c
1821+++ b/inflate.c
19- @@ -755 ,9 +755 ,10 @@ int ZEXPORT inflate(z_streamp strm, int flush)
22+ @@ -763 ,9 +763 ,10 @@ int flush;
2023 copy = state->length;
2124 if (copy > have) copy = have;
2225 if (copy) {
@@ -29,3 +32,35 @@ index e9ed74cff3279..2ecfb4876d155 100644
2932 zmemcpy(state->head->extra + len, next,
3033 len + copy > state->head->extra_max ?
3134 state->head->extra_max - len : copy);
35+
36+ From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001
37+ From: Mark Adler <fork@madler.net>
38+ Date: Mon, 8 Aug 2022 10:50:09 -0700
39+ Subject: [PATCH] Fix extra field processing bug that dereferences NULL
40+ state->head.
41+
42+ The recent commit to fix a gzip header extra field processing bug
43+ introduced the new bug fixed here.
44+ Upstream Reference : https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d
45+
46+ ---
47+ inflate.c | 4 ++--
48+ 1 file changed, 2 insertions(+), 2 deletions(-)
49+
50+ diff --git a/inflate.c b/inflate.c
51+ index 7a7289749..2a3c4fe98 100644
52+ --- a/inflate.c
53+ +++ b/inflate.c
54+ @@ -763,10 +763,10 @@ int flush;
55+ copy = state->length;
56+ if (copy > have) copy = have;
57+ if (copy) {
58+ - len = state->head->extra_len - state->length;
59+ if (state->head != Z_NULL &&
60+ state->head->extra != Z_NULL &&
61+ - len < state->head->extra_max) {
62+ + (len = state->head->extra_len - state->length) <
63+ + state->head->extra_max) {
64+ zmemcpy(state->head->extra + len, next,
65+ len + copy > state->head->extra_max ?
66+ state->head->extra_max - len : copy);
0 commit comments