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