unzip-zipbomb-part1.patch 1020 B

1234567891011121314151617181920212223242526
  1. From 41beb477c5744bc396fa1162ee0c14218ec12213 Mon Sep 17 00:00:00 2001
  2. From: Mark Adler <madler@alumni.caltech.edu>
  3. Date: Mon, 27 May 2019 08:20:32 -0700
  4. Subject: [PATCH] Fix bug in undefer_input() that misplaced the input state.
  5. ---
  6. fileio.c | 4 +++-
  7. 1 file changed, 3 insertions(+), 1 deletion(-)
  8. diff --git a/fileio.c b/fileio.c
  9. index c042987..bc00d74 100644
  10. --- a/fileio.c
  11. +++ b/fileio.c
  12. @@ -530,8 +530,10 @@ void undefer_input(__G)
  13. * This condition was checked when G.incnt_leftover was set > 0 in
  14. * defer_leftover_input(), and it is NOT allowed to touch G.csize
  15. * before calling undefer_input() when (G.incnt_leftover > 0)
  16. - * (single exception: see read_byte()'s "G.csize <= 0" handling) !!
  17. + * (single exception: see readbyte()'s "G.csize <= 0" handling) !!
  18. */
  19. + if (G.csize < 0L)
  20. + G.csize = 0L;
  21. G.incnt = G.incnt_leftover + (int)G.csize;
  22. G.inptr = G.inptr_leftover - (int)G.csize;
  23. G.incnt_leftover = 0;