From a544db3020b3f46b4050b4cf153ed3e4edd8a30a Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 2 Oct 2024 10:13:14 +0300 Subject: [PATCH] win32: zlib: Fix buffer overflow on inflate (CVE-2022-37434) --- win32port/zlib/inflate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/win32port/zlib/inflate.c b/win32port/zlib/inflate.c index 664c4b9cc..21631c75e 100644 --- a/win32port/zlib/inflate.c +++ b/win32port/zlib/inflate.c @@ -720,8 +720,9 @@ int flush; if (copy > have) copy = have; if (copy) { 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_len - state->length) < + state->head->extra_max) { zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy);