Blame SOURCES/0001-fix-CVE-2018-7725.patch

628a65
From 13f4d47275aca28de7b117359da79f1000e9bcb7 Mon Sep 17 00:00:00 2001
628a65
From: Jakub Martisko <jamartis@redhat.com>
628a65
Date: Wed, 23 May 2018 09:59:18 +0200
628a65
Subject: [PATCH] fix: CVE-2018-7725
628a65
628a65
---
628a65
 zzip/memdisk.c |  9 +++++++++
628a65
 zzip/mmapped.c | 11 ++++++++++-
628a65
 2 files changed, 19 insertions(+), 1 deletion(-)
628a65
628a65
diff --git a/zzip/memdisk.c b/zzip/memdisk.c
628a65
index dc00ea8..043893e 100644
628a65
--- a/zzip/memdisk.c
628a65
+++ b/zzip/memdisk.c
628a65
@@ -413,11 +413,21 @@ zzip_mem_entry_fopen(ZZIP_MEM_DISK * dir, ZZIP_MEM_ENTRY * entry)
628a65
     file->zlib.avail_in = zzip_mem_entry_csize(entry);
628a65
     file->zlib.next_in = zzip_mem_entry_to_data(entry);
628a65
 
628a65
+    if (file->zlib.next_in + file->zlib.avail_in >= file->endbuf)
628a65
+         goto error;
628a65
+    if (file->zlib.next_in < file->buffer)
628a65
+         goto error;
628a65
+
628a65
     if (! zzip_mem_entry_data_deflated(entry) ||
628a65
         inflateInit2(&file->zlib, -MAX_WBITS) != Z_OK)
628a65
         { free (file); return 0; }
628a65
 
628a65
     return file;
628a65
+
628a65
+error:
628a65
+    errno = EBADMSG;
628a65
+    free (file);
628a65
+    return NULL;
628a65
 }
628a65
 
628a65
 zzip__new__ ZZIP_MEM_DISK_FILE *
628a65
diff --git a/zzip/mmapped.c b/zzip/mmapped.c
628a65
index 6fafc11..ed3a6cc 100644
628a65
--- a/zzip/mmapped.c
628a65
+++ b/zzip/mmapped.c
628a65
@@ -549,7 +549,12 @@ zzip_disk_entry_fopen(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry)
628a65
     file->avail = zzip_file_header_usize(header);
628a65
 
628a65
     if (! file->avail || zzip_file_header_data_stored(header))
628a65
-        { file->stored = zzip_file_header_to_data (header); return file; }
628a65
+    { 
628a65
+        file->stored = zzip_file_header_to_data (header); 
628a65
+        if (file->stored + file->avail >= disk->endbuf)
628a65
+            goto error;
628a65
+        return file; 
628a65
+    }
628a65
 
628a65
     file->stored = 0;
628a65
     file->zlib.opaque = 0;
628a65
@@ -563,6 +568,10 @@ zzip_disk_entry_fopen(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry)
628a65
         { free (file); return 0; }
628a65
 
628a65
     return file;
628a65
+error:
628a65
+    free (file);
628a65
+    errno = EBADMSG;
628a65
+    return 0; 
628a65
     ____;
628a65
 }
628a65
 
628a65
-- 
628a65
2.14.3
628a65