Blame SOURCES/unzip-6.0-heap-overflow-infloop.patch

623fdc
From bdd4a0cecd745cb4825e4508b5bdf2579731086a Mon Sep 17 00:00:00 2001
623fdc
From: Petr Stodulka <pstodulk@redhat.com>
623fdc
Date: Mon, 14 Sep 2015 18:23:17 +0200
623fdc
Subject: [PATCH 1/3] upstream fix for heap overflow
623fdc
623fdc
https://bugzilla.redhat.com/attachment.cgi?id=1073002
623fdc
---
623fdc
 crypt.c | 12 +++++++++++-
623fdc
 1 file changed, 11 insertions(+), 1 deletion(-)
623fdc
623fdc
diff --git a/crypt.c b/crypt.c
623fdc
index 784e411..a8975f2 100644
623fdc
--- a/crypt.c
623fdc
+++ b/crypt.c
623fdc
@@ -465,7 +465,17 @@ int decrypt(__G__ passwrd)
623fdc
     GLOBAL(pInfo->encrypted) = FALSE;
623fdc
     defer_leftover_input(__G);
623fdc
     for (n = 0; n < RAND_HEAD_LEN; n++) {
623fdc
-        b = NEXTBYTE;
623fdc
+        /* 2012-11-23 SMS.  (OUSPG report.)
623fdc
+         * Quit early if compressed size < HEAD_LEN.  The resulting
623fdc
+         * error message ("unable to get password") could be improved,
623fdc
+         * but it's better than trying to read nonexistent data, and
623fdc
+         * then continuing with a negative G.csize.  (See
623fdc
+         * fileio.c:readbyte()).
623fdc
+         */
623fdc
+        if ((b = NEXTBYTE) == (ush)EOF)
623fdc
+        {
623fdc
+            return PK_ERR;
623fdc
+        }
623fdc
         h[n] = (uch)b;
623fdc
         Trace((stdout, " (%02x)", h[n]));
623fdc
     }
623fdc
-- 
623fdc
2.4.6
623fdc
623fdc
623fdc
From 4b48844661ff9569f2ecf582a387d46a5775b5d8 Mon Sep 17 00:00:00 2001
623fdc
From: Kamil Dudka <kdudka@redhat.com>
623fdc
Date: Mon, 14 Sep 2015 18:24:56 +0200
623fdc
Subject: [PATCH 2/3] fix infinite loop when extracting empty bzip2 data
623fdc
623fdc
Bug: https://sourceforge.net/p/infozip/patches/23/
623fdc
---
623fdc
 extract.c | 6 ++++++
623fdc
 1 file changed, 6 insertions(+)
623fdc
623fdc
diff --git a/extract.c b/extract.c
623fdc
index 7134bfe..29db027 100644
623fdc
--- a/extract.c
623fdc
+++ b/extract.c
623fdc
@@ -2733,6 +2733,12 @@ __GDEF
623fdc
     int repeated_buf_err;
623fdc
     bz_stream bstrm;
623fdc
 
623fdc
+    if (G.incnt <= 0 && G.csize <= 0L) {
623fdc
+        /* avoid an infinite loop */
623fdc
+        Trace((stderr, "UZbunzip2() got empty input\n"));
623fdc
+        return 2;
623fdc
+    }
623fdc
+
623fdc
 #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
623fdc
     if (G.redirect_slide)
623fdc
         wsize = G.redirect_size, redirSlide = G.redirect_buffer;
623fdc
-- 
623fdc
2.4.6
623fdc
623fdc
623fdc
From bd150334fb4084f5555a6be26b015a0671cb5b74 Mon Sep 17 00:00:00 2001
623fdc
From: Kamil Dudka <kdudka@redhat.com>
623fdc
Date: Tue, 22 Sep 2015 18:52:23 +0200
623fdc
Subject: [PATCH 3/3] extract: prevent unsigned overflow on invalid input
623fdc
623fdc
Suggested-by: Stefan Cornelius
623fdc
---
623fdc
 extract.c | 11 ++++++++++-
623fdc
 1 file changed, 10 insertions(+), 1 deletion(-)
623fdc
623fdc
diff --git a/extract.c b/extract.c
623fdc
index 29db027..b9ae667 100644
623fdc
--- a/extract.c
623fdc
+++ b/extract.c
623fdc
@@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk,
623fdc
         if (G.lrec.compression_method == STORED) {
623fdc
             zusz_t csiz_decrypted = G.lrec.csize;
623fdc
 
623fdc
-            if (G.pInfo->encrypted)
623fdc
+            if (G.pInfo->encrypted) {
623fdc
+                if (csiz_decrypted < 12) {
623fdc
+                    /* handle the error now to prevent unsigned overflow */
623fdc
+                    Info(slide, 0x401, ((char *)slide,
623fdc
+                      LoadFarStringSmall(ErrUnzipNoFile),
623fdc
+                      LoadFarString(InvalidComprData),
623fdc
+                      LoadFarStringSmall2(Inflate)));
623fdc
+                    return PK_ERR;
623fdc
+                }
623fdc
                 csiz_decrypted -= 12;
623fdc
+            }
623fdc
             if (G.lrec.ucsize != csiz_decrypted) {
623fdc
                 Info(slide, 0x401, ((char *)slide,
623fdc
                   LoadFarStringSmall2(WrnStorUCSizCSizDiff),
623fdc
-- 
623fdc
2.5.2
623fdc