Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP2
zziplib.13903
bsc1129403-prevent-division-by-zero.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc1129403-prevent-division-by-zero.patch of Package zziplib.13903
Index: zziplib-0.13.69/bins/unzip-mem.c =================================================================== --- zziplib-0.13.69.orig/bins/unzip-mem.c +++ zziplib-0.13.69/bins/unzip-mem.c @@ -186,6 +186,7 @@ static void zzip_mem_entry_direntry_star static void zzip_mem_entry_direntry_done (void) { char exp = ' '; + long percentage; if (sum_usize / 1024 > 1024*1024*1024) { exp = 'G'; sum_usize /= 1024*1024*1024; sum_usize /= 1024*1024*1024; } if (sum_usize > 1024*1024*1024) { exp = 'M'; @@ -199,9 +200,10 @@ static void zzip_mem_entry_direntry_done return; verbose: printf("-------- ------ ------- ----- ----\n"); + percentage = sum_usize ? (L (100 - (sum_csize*100/sum_usize))) : 0; /* 0% if file size is 0 */ printf("%8li%c %8li%c %3li%% %8li %s\n", L sum_usize, exp, L sum_csize, exp, - L (100 - (sum_csize*100/sum_usize)), L sum_files, + percentage, L sum_files, sum_files == 1 ? "file" : "files"); } @@ -231,9 +233,12 @@ static void zzip_mem_entry_direntry(ZZIP if (*name == '\n') name++; if (option_verbose) { + long percentage; + + percentage = usize ? (L (100 - (csize*100/usize))) : 0; /* 0% 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", Index: zziplib-0.13.69/test/zziptests.py =================================================================== --- zziplib-0.13.69.orig/test/zziptests.py +++ zziplib-0.13.69/test/zziptests.py @@ -3429,6 +3429,26 @@ class ZZipTest(unittest.TestCase): txt = open(txtfile).read() self.assertEqual(txt.split("\n"), run.output.split("\n")) + def test_65485_list_verbose_compressed_with_directory(self): + """ verbously list a zipfile containing directories """ + tmpdir = self.testdir() + workdir = tmpdir + "/d" + zipname = "ZIPfile" + os.makedirs(workdir) + f= open(tmpdir + "/d/file","w+") + for i in range(10): + f.write("This is line %d\r\n" % (i+1)) + f.close() + # create the ZIPfile + exe=self.bins("zzip") + run = shell("chdir {tmpdir} && ../{exe} -9 {zipname}.zip d".format(**locals())) + self.assertFalse(run.returncode) + # list the ZIPfile + exe=self.bins("unzip-mem"); + run = shell("chdir {tmpdir} && ../{exe} -v {zipname}.zip".format(**locals())) + self.assertFalse(run.returncode) + self.rm_testdir() + def test_99000_make_test1w_zip(self): """ create a test1w.zip using zzip/write functions. """ exe=self.bins("zzip")
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor