0018-unzip-6.0-heap-overflow-infloop.patch (3302B)
1 From bdd4a0cecd745cb4825e4508b5bdf2579731086a Mon Sep 17 00:00:00 2001 2 From: Petr Stodulka <pstodulk@redhat.com> 3 Date: Mon, 14 Sep 2015 18:23:17 +0200 4 Subject: [PATCH 1/3] upstream fix for heap overflow 5 6 https://bugzilla.redhat.com/attachment.cgi?id=1073002 7 --- 8 crypt.c | 12 +++++++++++- 9 1 file changed, 11 insertions(+), 1 deletion(-) 10 11 diff --git a/crypt.c b/crypt.c 12 index 784e411..a8975f2 100644 13 --- a/crypt.c 14 +++ b/crypt.c 15 @@ -465,7 +465,17 @@ int decrypt(__G__ passwrd) 16 GLOBAL(pInfo->encrypted) = FALSE; 17 defer_leftover_input(__G); 18 for (n = 0; n < RAND_HEAD_LEN; n++) { 19 - b = NEXTBYTE; 20 + /* 2012-11-23 SMS. (OUSPG report.) 21 + * Quit early if compressed size < HEAD_LEN. The resulting 22 + * error message ("unable to get password") could be improved, 23 + * but it's better than trying to read nonexistent data, and 24 + * then continuing with a negative G.csize. (See 25 + * fileio.c:readbyte()). 26 + */ 27 + if ((b = NEXTBYTE) == (ush)EOF) 28 + { 29 + return PK_ERR; 30 + } 31 h[n] = (uch)b; 32 Trace((stdout, " (%02x)", h[n])); 33 } 34 -- 35 2.4.6 36 37 38 From 4b48844661ff9569f2ecf582a387d46a5775b5d8 Mon Sep 17 00:00:00 2001 39 From: Kamil Dudka <kdudka@redhat.com> 40 Date: Mon, 14 Sep 2015 18:24:56 +0200 41 Subject: [PATCH 2/3] fix infinite loop when extracting empty bzip2 data 42 43 Bug: https://sourceforge.net/p/infozip/patches/23/ 44 --- 45 extract.c | 6 ++++++ 46 1 file changed, 6 insertions(+) 47 48 diff --git a/extract.c b/extract.c 49 index 7134bfe..29db027 100644 50 --- a/extract.c 51 +++ b/extract.c 52 @@ -2733,6 +2733,12 @@ __GDEF 53 int repeated_buf_err; 54 bz_stream bstrm; 55 56 + if (G.incnt <= 0 && G.csize <= 0L) { 57 + /* avoid an infinite loop */ 58 + Trace((stderr, "UZbunzip2() got empty input\n")); 59 + return 2; 60 + } 61 + 62 #if (defined(DLL) && !defined(NO_SLIDE_REDIR)) 63 if (G.redirect_slide) 64 wsize = G.redirect_size, redirSlide = G.redirect_buffer; 65 -- 66 2.4.6 67 68 69 From bd150334fb4084f5555a6be26b015a0671cb5b74 Mon Sep 17 00:00:00 2001 70 From: Kamil Dudka <kdudka@redhat.com> 71 Date: Tue, 22 Sep 2015 18:52:23 +0200 72 Subject: [PATCH 3/3] extract: prevent unsigned overflow on invalid input 73 74 Suggested-by: Stefan Cornelius 75 --- 76 extract.c | 11 ++++++++++- 77 1 file changed, 10 insertions(+), 1 deletion(-) 78 79 diff --git a/extract.c b/extract.c 80 index 29db027..b9ae667 100644 81 --- a/extract.c 82 +++ b/extract.c 83 @@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk, 84 if (G.lrec.compression_method == STORED) { 85 zusz_t csiz_decrypted = G.lrec.csize; 86 87 - if (G.pInfo->encrypted) 88 + if (G.pInfo->encrypted) { 89 + if (csiz_decrypted < 12) { 90 + /* handle the error now to prevent unsigned overflow */ 91 + Info(slide, 0x401, ((char *)slide, 92 + LoadFarStringSmall(ErrUnzipNoFile), 93 + LoadFarString(InvalidComprData), 94 + LoadFarStringSmall2(Inflate))); 95 + return PK_ERR; 96 + } 97 csiz_decrypted -= 12; 98 + } 99 if (G.lrec.ucsize != csiz_decrypted) { 100 Info(slide, 0x401, ((char *)slide, 101 LoadFarStringSmall2(WrnStorUCSizCSizDiff), 102 -- 103 2.5.2 104