ead5c7
From 81da2f651b65dbd2f387625d304ab14ed8b2ca29 Mon Sep 17 00:00:00 2001
ead5c7
From: Jakub Martisko <jamartis@redhat.com>
ead5c7
Date: Thu, 14 Jun 2018 09:19:41 +0200
ead5c7
Subject: [PATCH] fix: CVE-2018-7727
ead5c7
ead5c7
---
ead5c7
 bins/unzip-mem.c     | 2 +-
ead5c7
 bins/unzzipcat-mem.c | 7 +++----
ead5c7
 bins/unzzipdir-mem.c | 8 ++++----
ead5c7
 3 files changed, 8 insertions(+), 9 deletions(-)
ead5c7
ead5c7
diff --git a/bins/unzip-mem.c b/bins/unzip-mem.c
ead5c7
index 3f7d7f0..0b28b9b 100644
ead5c7
--- a/bins/unzip-mem.c
ead5c7
+++ b/bins/unzip-mem.c
ead5c7
@@ -409,7 +409,7 @@ main (int argc, char ** argv)
ead5c7
 	    }
ead5c7
 	}
ead5c7
     }
ead5c7
-
ead5c7
+    zzip_mem_disk_close(disk);
ead5c7
     return status;
ead5c7
 } 
ead5c7
 
ead5c7
diff --git a/bins/unzzipcat-mem.c b/bins/unzzipcat-mem.c
ead5c7
index 7474854..6f16989 100644
ead5c7
--- a/bins/unzzipcat-mem.c
ead5c7
+++ b/bins/unzzipcat-mem.c
ead5c7
@@ -93,10 +93,9 @@ main (int argc, char ** argv)
ead5c7
 	    char* name = zzip_mem_entry_to_name (entry);
ead5c7
 	    printf ("%s\n", name);
ead5c7
 	}
ead5c7
-	return 0;
ead5c7
     }
ead5c7
 
ead5c7
-    if (argc == 3)
ead5c7
+    else if (argc == 3)
ead5c7
     {  /* list from one spec */
ead5c7
 	ZZIP_MEM_ENTRY* entry = 0;
ead5c7
 	while ((entry = zzip_mem_disk_findmatch(disk, argv[2], entry, 0, 0)))
ead5c7
@@ -104,10 +103,9 @@ main (int argc, char ** argv)
ead5c7
 	     zzip_mem_entry_fprint (disk, entry, stdout);
ead5c7
 	}
ead5c7
 
ead5c7
-	return 0;
ead5c7
     }
ead5c7
 
ead5c7
-    for (argn=1; argn < argc; argn++)
ead5c7
+    else for (argn=1; argn < argc; argn++)
ead5c7
     {   /* list only the matching entries - each in order of commandline */
ead5c7
 	ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfirst(disk);
ead5c7
 	for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
ead5c7
@@ -118,6 +116,7 @@ main (int argc, char ** argv)
ead5c7
 		zzip_mem_disk_cat_file (disk, name, stdout);
ead5c7
 	}
ead5c7
     }
ead5c7
+    zzip_mem_disk_close(disk);
ead5c7
     return 0;
ead5c7
 } 
ead5c7
 
ead5c7
diff --git a/bins/unzzipdir-mem.c b/bins/unzzipdir-mem.c
ead5c7
index dc02077..9ebdb6d 100644
ead5c7
--- a/bins/unzzipdir-mem.c
ead5c7
+++ b/bins/unzzipdir-mem.c
ead5c7
@@ -64,10 +64,9 @@ main (int argc, char ** argv)
ead5c7
 	    char* name = zzip_mem_entry_to_name (entry);
ead5c7
 	    printf ("%s\n", name);
ead5c7
 	}
ead5c7
-	return 0;
ead5c7
     }
ead5c7
 
ead5c7
-    if (argc == 3)
ead5c7
+    else if (argc == 3)
ead5c7
     {  /* list from one spec */
ead5c7
 	ZZIP_MEM_ENTRY* entry = 0;
ead5c7
 	while ((entry = zzip_mem_disk_findmatch(disk, argv[2], entry, 0, 0)))
ead5c7
@@ -75,9 +74,9 @@ main (int argc, char ** argv)
ead5c7
 	    char* name = zzip_mem_entry_to_name (entry);
ead5c7
 	    printf ("%s\n", name);
ead5c7
 	}
ead5c7
-	return 0;
ead5c7
     }
ead5c7
 
ead5c7
+    else
ead5c7
     {   /* list only the matching entries - in order of zip directory */
ead5c7
 	ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfirst(disk);
ead5c7
 	for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
ead5c7
@@ -90,8 +89,9 @@ main (int argc, char ** argv)
ead5c7
 		    printf ("%s\n", name);
ead5c7
 	    }
ead5c7
 	}
ead5c7
-	return 0;
ead5c7
     }
ead5c7
+    zzip_mem_disk_close(disk);
ead5c7
+    return 0;
ead5c7
 } 
ead5c7
 
ead5c7
 /* 
ead5c7
-- 
ead5c7
2.14.4
ead5c7