From b15cf9dfa47ea7868dff1a1bd9579a4e9a0af475 Mon Sep 17 00:00:00 2001 From: Phuc-Thanh Nguyen <83806633+npt-1707@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:17:58 +0800 Subject: [PATCH] Fix a bug when getting a gzip header extra field with inflate() (#2471) --- extern/zlib/inflate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extern/zlib/inflate.c b/extern/zlib/inflate.c index ac333e8c2..d758a1cc8 100644 --- a/extern/zlib/inflate.c +++ b/extern/zlib/inflate.c @@ -758,9 +758,10 @@ int flush; copy = state->length; if (copy > have) copy = have; if (copy) { + len = state->head->extra_len - state->length; if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; + state->head->extra != Z_NULL && + len < state->head->extra_max) { zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy);