Message ID | 20230615145434.103140-1-oleksandr.suvorov@foundries.io |
---|---|
State | Accepted |
Commit | ef402577c2e3af6c3b967b2e4499b3796a37fde5 |
Delegated to: | Tom Rini |
Headers | show |
Series | lib/zlib: Fix a bug when getting a gzip header extra field | expand |
On Thu, Jun 15, 2023 at 05:54:34PM +0300, Oleksandr Suvorov wrote: > This fixes CVE-2022-37434 [1] and bases on 2 commits from Mark > Adler's zlib master repo - the original fix of CVE bug [2] and > the fix for the fix [3]. > > [1] > https://github.com/advisories/GHSA-cfmr-vrgj-vqwv > [2] > https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1 > [3] > https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d > > Fixes: e89516f031d ("zlib: split up to match original source tree") > Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Applied to u-boot/master, thanks!
diff --git a/lib/zlib/inflate.c b/lib/zlib/inflate.c index 30dfe155995..8f767b7b9d2 100644 --- a/lib/zlib/inflate.c +++ b/lib/zlib/inflate.c @@ -455,8 +455,9 @@ int ZEXPORT inflate(z_streamp strm, 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);
This fixes CVE-2022-37434 [1] and bases on 2 commits from Mark Adler's zlib master repo - the original fix of CVE bug [2] and the fix for the fix [3]. [1] https://github.com/advisories/GHSA-cfmr-vrgj-vqwv [2] https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1 [3] https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Fixes: e89516f031d ("zlib: split up to match original source tree") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> --- lib/zlib/inflate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)