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