CVE-2022-37434-1.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001
  2. From: Mark Adler <fork@madler.net>
  3. Date: Sat, 30 Jul 2022 15:51:11 -0700
  4. Subject: [PATCH] Fix a bug when getting a gzip header extra field with
  5. inflate().
  6. If the extra field was larger than the space the user provided with
  7. inflateGetHeader(), and if multiple calls of inflate() delivered
  8. the extra header data, then there could be a buffer overflow of the
  9. provided space. This commit assures that provided space is not
  10. exceeded.
  11. (Ref: https://github.com/madler/zlib/commit/eff308af4)
  12. ---
  13. inflate.c | 5 +++--
  14. 1 file changed, 3 insertions(+), 2 deletions(-)
  15. --- zlib-1.2.11.dfsg.orig/inflate.c
  16. +++ zlib-1.2.11.dfsg/inflate.c
  17. @@ -758,9 +758,10 @@ int flush;
  18. copy = state->length;
  19. if (copy > have) copy = have;
  20. if (copy) {
  21. + len = state->head->extra_len - state->length;
  22. if (state->head != Z_NULL &&
  23. - state->head->extra != Z_NULL) {
  24. - len = state->head->extra_len - state->length;
  25. + state->head->extra != Z_NULL &&
  26. + len < state->head->extra_max) {
  27. zmemcpy(state->head->extra + len, next,
  28. len + copy > state->head->extra_max ?
  29. state->head->extra_max - len : copy);