From: Wayne Davison Date: Sun, 7 Aug 2022 16:27:57 +0000 (-0700) Subject: Fix zlib bug with a large gzip header extra field X-Git-Tag: v3.2.5pre2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=788f11ea6afeb96f0d84f140192165a1ca12ade4;p=thirdparty%2Frsync.git Fix zlib bug with a large gzip header extra field From zlib commit eff308af425b67093bab25f80f1ae950166bece1. Fixes CVE-2022-37434. --- diff --git a/zlib/inflate.c b/zlib/inflate.c index e43abd9e..d15132ea 100644 --- a/zlib/inflate.c +++ b/zlib/inflate.c @@ -739,9 +739,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);