contrib/zziplib/0010-Prevent-division-by-zero.patch
2019-07-06 15:05:38 -04:00

31 lines
939 B
Diff

From 220b12635668fd524f950fd2e5c7635a43a90bdd Mon Sep 17 00:00:00 2001
From: Josef Moellers <jmoellers@suse.de>
Date: Mon, 1 Apr 2019 16:28:00 +0200
Subject: [PATCH 10/19] Prevent division by zero
---
bins/unzip-mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bins/unzip-mem.c b/bins/unzip-mem.c
index c45cb72..c576290 100644
--- a/bins/unzip-mem.c
+++ b/bins/unzip-mem.c
@@ -231,9 +231,12 @@ static void zzip_mem_entry_direntry(ZZIP_MEM_ENTRY* entry)
if (*name == '\n') name++;
if (option_verbose) {
+ long percentage;
+
+ percentage = usize ? (L (100 - (csize*100/usize))) : 100; /* 100% if file size is 0 */
printf("%8li%c %s %8li%c%3li%% %s %8lx %s %s\n",
L usize, exp, comprlevel[compr], L csize, exp,
- L (100 - (csize*100/usize)),
+ percentage,
_zzip_ctime(&mtime), crc32, name, comment);
} else {
printf(" %8li%c %s %s %s\n",
--
2.22.0