]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Fix zlib bug with a large gzip header extra field
authorWayne Davison <wayne@opencoder.net>
Sun, 7 Aug 2022 16:27:57 +0000 (09:27 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 7 Aug 2022 16:34:26 +0000 (09:34 -0700)
From zlib commit eff308af425b67093bab25f80f1ae950166bece1.
Fixes CVE-2022-37434.

zlib/inflate.c

index e43abd9e02fadb4c63cbf37220f25edc2c156d18..d15132eaf04ab4d177cb40a8480ab1ced8ab6082 100644 (file)
@@ -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);