|
|
79f270 |
From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001
|
|
|
79f270 |
From: Mark Adler <fork@madler.net>
|
|
|
79f270 |
Date: Sat, 30 Jul 2022 15:51:11 -0700
|
|
|
79f270 |
Subject: [PATCH] Fix a bug when getting a gzip header extra field with
|
|
|
79f270 |
inflate().
|
|
|
79f270 |
|
|
|
79f270 |
If the extra field was larger than the space the user provided with
|
|
|
79f270 |
inflateGetHeader(), and if multiple calls of inflate() delivered
|
|
|
79f270 |
the extra header data, then there could be a buffer overflow of the
|
|
|
79f270 |
provided space. This commit assures that provided space is not
|
|
|
79f270 |
exceeded.
|
|
|
79f270 |
---
|
|
|
79f270 |
inflate.c | 5 +++--
|
|
|
79f270 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
79f270 |
|
|
|
79f270 |
diff --git a/inflate.c b/inflate.c
|
|
|
79f270 |
index 7be8c63..7a72897 100644
|
|
|
79f270 |
--- a/inflate.c
|
|
|
79f270 |
+++ b/inflate.c
|
|
|
79f270 |
@@ -763,9 +763,10 @@ int flush;
|
|
|
79f270 |
copy = state->length;
|
|
|
79f270 |
if (copy > have) copy = have;
|
|
|
79f270 |
if (copy) {
|
|
|
79f270 |
+ len = state->head->extra_len - state->length;
|
|
|
79f270 |
if (state->head != Z_NULL &&
|
|
|
79f270 |
- state->head->extra != Z_NULL) {
|
|
|
79f270 |
- len = state->head->extra_len - state->length;
|
|
|
79f270 |
+ state->head->extra != Z_NULL &&
|
|
|
79f270 |
+ len < state->head->extra_max) {
|
|
|
79f270 |
zmemcpy(state->head->extra + len, next,
|
|
|
79f270 |
len + copy > state->head->extra_max ?
|
|
|
79f270 |
state->head->extra_max - len : copy);
|
|
|
79f270 |
--
|
|
|
79f270 |
2.35.3
|
|
|
79f270 |
|