From: Josef Moellers Date: Mon, 1 Apr 2019 14:28:00 +0000 (+0200) Subject: Prevent division by zero X-Git-Tag: v0.13.70~6^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=220b12635668fd524f950fd2e5c7635a43a90bdd;p=zziplib Prevent division by zero --- 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",