| 1 |
import unittest |
| 2 |
import subprocess |
| 3 |
import logging |
| 4 |
import inspect |
| 5 |
import sys |
| 6 |
import os |
| 7 |
import collections |
| 8 |
import shutil |
| 9 |
import random |
| 10 |
import re |
| 11 |
import errno |
| 12 |
from fnmatch import fnmatchcase as matches |
| 13 |
|
| 14 |
try: |
| 15 |
from cStringIO import StringIO |
| 16 |
except ImportError: |
| 17 |
from io import StringIO |
| 18 |
|
| 19 |
try: |
| 20 |
from urllib import quote_plus, urlretrieve |
| 21 |
except ImportError: |
| 22 |
from urllib.parse import quote_plus |
| 23 |
from urllib.request import urlretrieve |
| 24 |
|
| 25 |
if sys.version[0] == '3': |
| 26 |
basestring = str |
| 27 |
|
| 28 |
logg = logging.getLogger("test") |
| 29 |
|
| 30 |
topsrcdir = "../.." |
| 31 |
testdatadir = "testdata.d" |
| 32 |
readme = "README" |
| 33 |
mkzip = "zip" |
| 34 |
unzip = "unzip" |
| 35 |
unzip_skip = False |
| 36 |
exeext = "" |
| 37 |
bindir = os.path.join("..", "bins") |
| 38 |
downloaddir = "tmp.download" |
| 39 |
downloadonly = False |
| 40 |
nodownloads = False |
| 41 |
|
| 42 |
def yesno(text): |
| 43 |
if not text: return False |
| 44 |
if text.lower() in ["y", "yes", "t", "true", "on", "ok"]: |
| 45 |
return True |
| 46 |
return False |
| 47 |
|
| 48 |
def decodes(text): |
| 49 |
if text is None: return None |
| 50 |
if isinstance(text, bytes): |
| 51 |
encoded = sys.getdefaultencoding() |
| 52 |
if encoded in ["ascii"]: |
| 53 |
encoded = "utf-8" |
| 54 |
try: |
| 55 |
return text.decode(encoded) |
| 56 |
except: |
| 57 |
return text.decode("latin-1") |
| 58 |
|
| 59 |
def shell_string(command): |
| 60 |
return " ".join(["'%s'" % arg.replace("'","\\'") for arg in command]) |
| 61 |
|
| 62 |
def shell(command, shell=True, calls=False, cwd=None, env=None, lang=None, returncodes=None): |
| 63 |
returncodes = returncodes or [ None, 0 ] |
| 64 |
Shell = collections.namedtuple("Shell",["returncode", "output", "errors", "shell"]) |
| 65 |
if isinstance(command, basestring): |
| 66 |
sh_command = command |
| 67 |
command = [ command ] |
| 68 |
else: |
| 69 |
sh_command = shell_string(command) |
| 70 |
if not env: |
| 71 |
env = os.environ.copy() |
| 72 |
if lang: |
| 73 |
for name, value in env.items(): |
| 74 |
if name.startswith("LC_"): |
| 75 |
env[name] = lang |
| 76 |
env["LANG"] = lang # defines message format |
| 77 |
env["LC_ALL"] = lang # other locale formats |
| 78 |
zzip_libs = "/zzip/.libs" |
| 79 |
zzip_cmds = command[0].split(" ")[0] |
| 80 |
build_lib1 = os.path.dirname(os.path.realpath(zzip_cmds)) |
| 81 |
build_lib2 = os.path.dirname(build_lib1) |
| 82 |
build_lib3 = os.path.dirname(build_lib2) |
| 83 |
if os.path.isdir(build_lib1 + zzip_libs): |
| 84 |
env["LD_LIBRARY_PATH"] = build_lib1 + zzip_libs |
| 85 |
elif os.path.isdir(build_lib2 + zzip_libs): |
| 86 |
env["LD_LIBRARY_PATH"] = build_lib2 + zzip_libs |
| 87 |
elif os.path.isdir(build_lib3 + zzip_libs): |
| 88 |
env["LD_LIBRARY_PATH"] = build_lib3 + zzip_libs |
| 89 |
try: |
| 90 |
output, errors = "", "" |
| 91 |
if calls: |
| 92 |
logg.debug("result from %s: %s", cwd and cwd+"/" or "shell", sh_command) |
| 93 |
run = subprocess.Popen(command, shell=shell, cwd=cwd, env=env) |
| 94 |
if run.returncode: |
| 95 |
logg.warning("EXIT %s: %s", run.returncode, command) |
| 96 |
run.wait() |
| 97 |
else: |
| 98 |
logg.debug("output from %s: %s", cwd and cwd+"/" or "shell", sh_command) |
| 99 |
run = subprocess.Popen(command, shell=shell, cwd=cwd, |
| 100 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=None, env=env) |
| 101 |
if run.returncode: |
| 102 |
logg.warning("EXIT %s: %s", run.returncode, command) |
| 103 |
out, err = run.communicate() |
| 104 |
output = decodes(out) |
| 105 |
errors = decodes(err) |
| 106 |
except: |
| 107 |
logg.error("*E*: %s", sh_command) |
| 108 |
for line in output.split("\n"): |
| 109 |
if line: |
| 110 |
logg.error("OUT: %s", line) |
| 111 |
for line in errors.split("\n"): |
| 112 |
if line: |
| 113 |
logg.error("ERR: %s", line) |
| 114 |
raise |
| 115 |
if run.returncode not in returncodes: |
| 116 |
logg.warning("*%02i: %s", run.returncode, sh_command) |
| 117 |
for line in output.split("\n"): |
| 118 |
if line: |
| 119 |
logg.warning("OUT: %s", line) |
| 120 |
for line in errors.split("\n"): |
| 121 |
if line: |
| 122 |
logg.warning("ERR: %s", line) |
| 123 |
raise subprocess.CalledProcessError(run.returncode, sh_command, output) |
| 124 |
else: |
| 125 |
for line in output.split("\n"): |
| 126 |
if line: |
| 127 |
logg.debug("OUT: %s", line) |
| 128 |
for line in errors.split("\n"): |
| 129 |
if line: |
| 130 |
logg.debug("ERR: %s", line) |
| 131 |
return Shell(run.returncode, output, errors, sh_command) |
| 132 |
|
| 133 |
def get_caller_name(): |
| 134 |
frame = inspect.currentframe().f_back.f_back |
| 135 |
return frame.f_code.co_name |
| 136 |
def get_caller_caller_name(): |
| 137 |
frame = inspect.currentframe().f_back.f_back.f_back |
| 138 |
return frame.f_code.co_name |
| 139 |
|
| 140 |
def download_raw(base_url, filename, into, style = "?raw=true"): |
| 141 |
return download(base_url, filename, into, style) |
| 142 |
def download(base_url, filename, into = None, style = ""): |
| 143 |
if nodownloads: |
| 144 |
return False |
| 145 |
data = downloaddir |
| 146 |
if not os.path.isdir(data): |
| 147 |
os.makedirs(data) |
| 148 |
subname = quote_plus(base_url) |
| 149 |
subdir = os.path.join(data, subname) |
| 150 |
if not os.path.isdir(subdir): |
| 151 |
os.makedirs(subdir) |
| 152 |
subfile = os.path.join(subdir, filename) |
| 153 |
if not os.path.exists(subfile) and "---" in base_url: |
| 154 |
my_downloads = os.path.expanduser("~/Downloads") |
| 155 |
srcfile = os.path.join(my_downloads, filename) |
| 156 |
if os.path.exists(srcfile): |
| 157 |
shutil.copy(srcfile, subfile) |
| 158 |
if not os.path.exists(subfile): |
| 159 |
logg.info("need %s", subfile) |
| 160 |
try: |
| 161 |
url = base_url + "/" + filename + style |
| 162 |
url = url.replace("/blob/", "/raw/") |
| 163 |
logg.info("curl %s", url) |
| 164 |
urlretrieve(url, subfile) |
| 165 |
except: |
| 166 |
# Ensure zero-length file exists in case we couldn't |
| 167 |
# download the file so that we won't try to |
| 168 |
# re-download it. |
| 169 |
open(subfile, 'a').close() |
| 170 |
if not os.path.exists(subfile): |
| 171 |
return None |
| 172 |
if os.path.getsize(subfile) < 5: |
| 173 |
return None |
| 174 |
# |
| 175 |
if into: |
| 176 |
if not os.path.isdir(into): |
| 177 |
os.makedirs(into) |
| 178 |
intofile = os.path.join(into, filename) |
| 179 |
shutil.copy(subfile, intofile) |
| 180 |
logg.debug("copied %s -> %s", subfile, intofile) |
| 181 |
return filename |
| 182 |
|
| 183 |
def output(cmd, shell=True): |
| 184 |
run = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE) |
| 185 |
out, err = run.communicate() |
| 186 |
return out.decode('utf-8') |
| 187 |
def grep(pattern, lines): |
| 188 |
if isinstance(lines, basestring): |
| 189 |
lines = lines.split("\n") |
| 190 |
for line in lines: |
| 191 |
if re.search(pattern, line.rstrip()): |
| 192 |
yield line.rstrip() |
| 193 |
def greps(lines, pattern): |
| 194 |
return list(grep(pattern, lines)) |
| 195 |
def all_errors(lines): |
| 196 |
if isinstance(lines, basestring): |
| 197 |
lines = lines.split("\n") |
| 198 |
for line in lines: |
| 199 |
if not line.strip(): |
| 200 |
continue |
| 201 |
if "DEBUG:" in line: |
| 202 |
continue |
| 203 |
if "HINT:" in line: |
| 204 |
continue |
| 205 |
yield line.rstrip() |
| 206 |
def errors(lines): |
| 207 |
return list(all_errors(lines)) |
| 208 |
|
| 209 |
class ZZipTest(unittest.TestCase): |
| 210 |
@property |
| 211 |
def t(self): |
| 212 |
if not os.path.isdir(testdatadir): |
| 213 |
os.makedirs(testdatadir) |
| 214 |
return testdatdir |
| 215 |
@property |
| 216 |
def s(self): |
| 217 |
return topsrcdir |
| 218 |
def src(self, name): |
| 219 |
return os.path.join(self.s, name) |
| 220 |
def assertErrorMessage(self, errors, errno): |
| 221 |
self.assertIn(': ' + os.strerror(errno), errors) |
| 222 |
def readme(self): |
| 223 |
f = open(self.src(readme)) |
| 224 |
text = f.read() |
| 225 |
f.close() |
| 226 |
return text |
| 227 |
def mkfile(self, name, content): |
| 228 |
b = os.path.dirname(name) |
| 229 |
if not os.path.isdir(b): |
| 230 |
os.makedirs(b) |
| 231 |
f = open(name, "w") |
| 232 |
f.write(content) |
| 233 |
f.close() |
| 234 |
def bins(self, name): |
| 235 |
if name == "unzip": return unzip |
| 236 |
if name == "mkzip": return mkzip |
| 237 |
exe = os.path.join(bindir, name) |
| 238 |
if exeext: exe += exeext |
| 239 |
return exe |
| 240 |
def gdb_bins(self, name): |
| 241 |
if name == "unzip": return unzip |
| 242 |
if name == "mkzip": return mkzip |
| 243 |
exe = os.path.join(bindir, ".libs", name) |
| 244 |
if exeext: exe += exeext |
| 245 |
return exe |
| 246 |
def gentext(self, size): |
| 247 |
random.seed(1234567891234567890) |
| 248 |
result = StringIO() |
| 249 |
old1 = '' |
| 250 |
old2 = '' |
| 251 |
for i in range(size): |
| 252 |
while True: |
| 253 |
x = random.choice(" abcdefghijklmnopqrstuvwxyz\n") |
| 254 |
if x == old1 or x == old2: continue |
| 255 |
old1 = old2 |
| 256 |
old2 = x |
| 257 |
break |
| 258 |
result.write(x) |
| 259 |
return result.getvalue() |
| 260 |
def caller_testname(self): |
| 261 |
name = get_caller_caller_name() |
| 262 |
x1 = name.find("_") |
| 263 |
if x1 < 0: return name |
| 264 |
x2 = name.find("_", x1+1) |
| 265 |
if x2 < 0: return name |
| 266 |
return name[:x2] |
| 267 |
def testname(self, suffix = None): |
| 268 |
name = self.caller_testname() |
| 269 |
if suffix: |
| 270 |
return name + "_" + suffix |
| 271 |
return name |
| 272 |
def testzip(self, testname = None): |
| 273 |
testname = testname or self.caller_testname() |
| 274 |
zipname = testname + ".zip" |
| 275 |
return zipname |
| 276 |
def testdir(self, testname = None): |
| 277 |
testname = testname or self.caller_testname() |
| 278 |
newdir = "tmp."+testname |
| 279 |
if os.path.isdir(newdir): |
| 280 |
shutil.rmtree(newdir) |
| 281 |
os.makedirs(newdir) |
| 282 |
return newdir |
| 283 |
def rm_testdir(self, testname = None): |
| 284 |
testname = testname or self.caller_testname() |
| 285 |
newdir = "tmp."+testname |
| 286 |
if os.path.isdir(newdir): |
| 287 |
shutil.rmtree(newdir) |
| 288 |
return newdir |
| 289 |
def rm_testzip(self, testname = None): |
| 290 |
testname = testname or self.caller_testname() |
| 291 |
zipname = testname + ".zip" |
| 292 |
if os.path.exists(zipname): |
| 293 |
os.remove(zipname) |
| 294 |
return True |
| 295 |
################################################################ |
| 296 |
def test_1000_make_test0_zip(self): |
| 297 |
""" create a test.zip for later tests using standard 'zip' |
| 298 |
It will fall back to a variant in the source code if 'zip' |
| 299 |
is not installed on the build host. The content is just |
| 300 |
the README file that we can check for equality later on. """ |
| 301 |
zipfile="test0.zip" |
| 302 |
tmpdir="test0.tmp" |
| 303 |
exe=self.bins("mkzip") |
| 304 |
filename = os.path.join(tmpdir,"README") |
| 305 |
filetext = self.readme() |
| 306 |
self.mkfile(filename, filetext) |
| 307 |
shell("{exe} ../{zipfile} README".format(**locals()), cwd=tmpdir) |
| 308 |
self.assertGreater(os.path.getsize(zipfile), 10) |
| 309 |
def test_10001_make_test1_zip(self): |
| 310 |
""" create a test1.zip for later tests using standard 'zip' |
| 311 |
It will fall back to a variant in the source code if 'zip' |
| 312 |
is not installed on the build host. The archive has 10 |
| 313 |
generic files that we can check for their content later. """ |
| 314 |
zipfile="test1.zip" |
| 315 |
tmpdir="test1.tmp" |
| 316 |
exe=self.bins("mkzip") |
| 317 |
for i in [1,2,3,4,5,6,7,8,9]: |
| 318 |
filename = os.path.join(tmpdir,"file.%i" % i) |
| 319 |
filetext = "file-%i\n" % i |
| 320 |
self.mkfile(filename, filetext) |
| 321 |
filename = os.path.join(tmpdir,"README") |
| 322 |
filetext = self.readme() |
| 323 |
self.mkfile(filename, filetext) |
| 324 |
shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir) |
| 325 |
self.assertGreater(os.path.getsize(zipfile), 10) |
| 326 |
def test_10002_make_test2_zip(self): |
| 327 |
""" create a test2.zip for later tests using standard 'zip' |
| 328 |
It will NOT fall back to a variant in the source code. |
| 329 |
The archive has 100 generic files with known content. """ |
| 330 |
zipfile="test2.zip" |
| 331 |
tmpdir="test2.tmp" |
| 332 |
exe=self.bins("mkzip") |
| 333 |
for i in range(100): |
| 334 |
filename = os.path.join(tmpdir,"file.%02i" % i) |
| 335 |
filetext = "file-%02i\n" % i |
| 336 |
self.mkfile(filename, filetext) |
| 337 |
filename = os.path.join(tmpdir,"README") |
| 338 |
filetext = self.readme() |
| 339 |
self.mkfile(filename, filetext) |
| 340 |
shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir) |
| 341 |
self.assertGreater(os.path.getsize(zipfile), 10) |
| 342 |
def test_10003_make_test3_zip(self): |
| 343 |
""" create a test3.zip for later tests using standard 'zip' |
| 344 |
It will NOT fall back to a variant in the source code. |
| 345 |
The archive has 1000 generic files with known content. """ |
| 346 |
zipfile="test3.zip" |
| 347 |
tmpdir="test3.tmp" |
| 348 |
exe=self.bins("mkzip") |
| 349 |
for i in range(1000): |
| 350 |
filename = os.path.join(tmpdir,"file.%03i" % i) |
| 351 |
filetext = "file-%03i\n" % i |
| 352 |
self.mkfile(filename, filetext) |
| 353 |
filename = os.path.join(tmpdir,"README") |
| 354 |
filetext = self.readme() |
| 355 |
self.mkfile(filename, filetext) |
| 356 |
shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir) |
| 357 |
self.assertGreater(os.path.getsize(zipfile), 10) |
| 358 |
def test_10004_make_test4_zip(self): |
| 359 |
""" create a test4.zip for later tests using standard 'zip' |
| 360 |
It will NOT fall back to a variant in the source code. |
| 361 |
The archive has 10000 generic files with known content |
| 362 |
and they are stored (NOT compressed) in the archive. """ |
| 363 |
zipfile="test4.zip" |
| 364 |
tmpdir="test4.tmp" |
| 365 |
exe=self.bins("mkzip") |
| 366 |
for i in range(10000): |
| 367 |
filename = os.path.join(tmpdir,"file%04i.txt" % i) |
| 368 |
filetext = "file-%04i\n" % i |
| 369 |
self.mkfile(filename, filetext) |
| 370 |
filename = os.path.join(tmpdir,"README") |
| 371 |
filetext = self.readme() |
| 372 |
self.mkfile(filename, filetext) |
| 373 |
shell("{exe} -n README ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir) |
| 374 |
self.assertGreater(os.path.getsize(zipfile), 1000000) |
| 375 |
def test_10005_make_test5_zip(self): |
| 376 |
""" create a test5.zip for later tests using standard 'zip' |
| 377 |
It will NOT fall back to a variant in the source code. |
| 378 |
The archive has files at multiple subdirectories depth |
| 379 |
and of varying sizes each. """ |
| 380 |
zipfile="test5.zip" |
| 381 |
tmpdir="test5.tmp" |
| 382 |
exe=self.bins("mkzip") |
| 383 |
for depth in range(20): |
| 384 |
dirpath = "" |
| 385 |
for i in range(depth): |
| 386 |
if i: |
| 387 |
dirpath += "subdir%i/" % i |
| 388 |
for size in range(18): |
| 389 |
size = 2 ** size |
| 390 |
filetext = self.gentext(size) |
| 391 |
filepart = "file%i-%i.txt" % (depth, size) |
| 392 |
filename = os.path.join(tmpdir, dirpath + filepart ) |
| 393 |
self.mkfile(filename, filetext) |
| 394 |
filename = os.path.join(tmpdir,"README") |
| 395 |
filetext = self.readme() |
| 396 |
self.mkfile(filename, filetext) |
| 397 |
shell("{exe} ../{zipfile} -r file* subdir* README".format(**locals()), cwd=tmpdir) |
| 398 |
self.assertGreater(os.path.getsize(zipfile), 1000000) |
| 399 |
def test_10010_make_test0_dat(self): |
| 400 |
""" create test.dat from test.zip with xorcopy """ |
| 401 |
zipfile = "test0.zip" |
| 402 |
datfile = "test0x.dat" |
| 403 |
exe = self.bins("zzxorcopy") |
| 404 |
shell("{exe} {zipfile} {datfile}".format(**locals())) |
| 405 |
self.assertGreater(os.path.getsize(datfile), 10) |
| 406 |
self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile)) |
| 407 |
def test_10011_make_test1_dat(self): |
| 408 |
""" create test.dat from test.zip with xorcopy """ |
| 409 |
zipfile = "test1.zip" |
| 410 |
datfile = "test1x.dat" |
| 411 |
exe = self.bins("zzxorcopy") |
| 412 |
shell("{exe} {zipfile} {datfile}".format(**locals())) |
| 413 |
self.assertGreater(os.path.getsize(datfile), 10) |
| 414 |
self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile)) |
| 415 |
def test_10012_make_test2_dat(self): |
| 416 |
""" create test.dat from test.zip with xorcopy """ |
| 417 |
zipfile = "test2.zip" |
| 418 |
datfile = "test2x.dat" |
| 419 |
exe = self.bins("zzxorcopy") |
| 420 |
shell("{exe} {zipfile} {datfile}".format(**locals())) |
| 421 |
self.assertGreater(os.path.getsize(datfile), 10) |
| 422 |
self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile)) |
| 423 |
def test_10013_make_test3_dat(self): |
| 424 |
""" create test.dat from test.zip with xorcopy """ |
| 425 |
zipfile = "test3.zip" |
| 426 |
datfile = "test3x.dat" |
| 427 |
exe = self.bins("zzxorcopy") |
| 428 |
shell("{exe} {zipfile} {datfile}".format(**locals())) |
| 429 |
self.assertGreater(os.path.getsize(datfile), 10) |
| 430 |
self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile)) |
| 431 |
def test_10014_make_test4_dat(self): |
| 432 |
""" create test.dat from test.zip with xorcopy """ |
| 433 |
zipfile = "test4.zip" |
| 434 |
datfile = "test4x.dat" |
| 435 |
exe = self.bins("zzxorcopy") |
| 436 |
shell("{exe} {zipfile} {datfile}".format(**locals())) |
| 437 |
self.assertGreater(os.path.getsize(datfile), 10) |
| 438 |
self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile)) |
| 439 |
def test_20000_zziptest_test0_zip(self): |
| 440 |
""" run zziptest on test.zip """ |
| 441 |
zipfile = "test0.zip" |
| 442 |
logfile = "test0.log" |
| 443 |
exe = self.bins("zziptest") |
| 444 |
shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals())) |
| 445 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 446 |
def test_20001_zziptest_test1_zip(self): |
| 447 |
""" run zziptest on test.zip """ |
| 448 |
zipfile = "test1.zip" |
| 449 |
logfile = "test1.log" |
| 450 |
exe = self.bins("zziptest") |
| 451 |
shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals())) |
| 452 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 453 |
def test_20002_zziptest_test2_zip(self): |
| 454 |
""" run zziptest on test.zip """ |
| 455 |
zipfile = "test2.zip" |
| 456 |
logfile = "test2.log" |
| 457 |
exe = self.bins("zziptest") |
| 458 |
shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals())) |
| 459 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 460 |
def test_20003_zziptest_test3_zip(self): |
| 461 |
""" run zziptest on test.zip """ |
| 462 |
zipfile = "test3.zip" |
| 463 |
logfile = "test3.log" |
| 464 |
exe = self.bins("zziptest") |
| 465 |
shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals())) |
| 466 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 467 |
def test_20004_zziptest_test4_zip(self): |
| 468 |
""" run zziptest on test.zip """ |
| 469 |
zipfile = "test4.zip" |
| 470 |
logfile = "test4.log" |
| 471 |
exe = self.bins("zziptest") |
| 472 |
shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals())) |
| 473 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 474 |
def test_20010_zzcat_test0_zip(self): |
| 475 |
""" run zzcat on test.zip using just test/README """ |
| 476 |
zipfile = "test0.zip" |
| 477 |
getfile = "test0/README" |
| 478 |
logfile = "test0.readme.txt" |
| 479 |
exe = self.bins("zzcat") |
| 480 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 481 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 482 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 483 |
def test_20011_zzcat_test1_zip(self): |
| 484 |
""" run zzcat on test.zip using just test/README """ |
| 485 |
zipfile = "test1.zip" |
| 486 |
getfile = "test1/README" |
| 487 |
logfile = "test1.readme.txt" |
| 488 |
exe = self.bins("zzcat") |
| 489 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 490 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 491 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 492 |
getfile = "test1/file.1" |
| 493 |
run = shell("{exe} {getfile}".format(**locals())) |
| 494 |
self.assertEqual("file-1\n", run.output) |
| 495 |
def test_20012_zzcat_test2_zip(self): |
| 496 |
""" run zzcat on test.zip using just test/README """ |
| 497 |
zipfile = "test2.zip" |
| 498 |
getfile = "test2/README" |
| 499 |
logfile = "test2.readme.txt" |
| 500 |
exe = self.bins("zzcat") |
| 501 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 502 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 503 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 504 |
getfile = "test2/file.22" |
| 505 |
run = shell("{exe} {getfile}".format(**locals())) |
| 506 |
self.assertEqual("file-22\n", run.output) |
| 507 |
def test_20013_zzcat_test3_zip(self): |
| 508 |
""" run zzcat on test.zip using just test/README """ |
| 509 |
zipfile = "test3.zip" |
| 510 |
getfile = "test3/README" |
| 511 |
logfile = "test3.readme.txt" |
| 512 |
exe = self.bins("zzcat") |
| 513 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 514 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 515 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 516 |
getfile = "test3/file.999" |
| 517 |
run = shell("{exe} {getfile}".format(**locals())) |
| 518 |
self.assertEqual("file-999\n", run.output) |
| 519 |
def test_20014_zzcat_test4_zip(self): |
| 520 |
""" run zzcat on test.zip using just test/README """ |
| 521 |
zipfile = "test4.zip" |
| 522 |
getfile = "test4/README" |
| 523 |
logfile = "test4.readme.txt" |
| 524 |
exe = self.bins("zzcat") |
| 525 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 526 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 527 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 528 |
getfile = "test4/file9999.txt" |
| 529 |
run = shell("{exe} {getfile}".format(**locals())) |
| 530 |
self.assertEqual("file-9999\n", run.output) |
| 531 |
def test_20020_zzdir_test0_zip(self): |
| 532 |
""" run zzdir on test0.zip using just 'test0' """ |
| 533 |
zipfile = "test0.zip" |
| 534 |
getfile = "test0" |
| 535 |
exe = self.bins("zzdir") |
| 536 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 537 |
self.assertIn(' README\n', run.output) |
| 538 |
self.assertIn(' defl:N ', run.output) |
| 539 |
self.assertLess(len(run.output), 30) |
| 540 |
def test_20021_zzdir_test1_zip(self): |
| 541 |
""" run zzdir on test1.zip using just 'test1' """ |
| 542 |
zipfile = "test1.zip" |
| 543 |
getfile = "test1" |
| 544 |
exe = self.bins("zzdir") |
| 545 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 546 |
self.assertIn(' file.1\n', run.output) |
| 547 |
self.assertIn(' file.2\n', run.output) |
| 548 |
self.assertIn(' file.9\n', run.output) |
| 549 |
self.assertIn(' README\n', run.output) |
| 550 |
self.assertIn(' defl:N ', run.output) |
| 551 |
self.assertIn(' stored ', run.output) |
| 552 |
def test_20022_zzdir_test2_zip(self): |
| 553 |
""" run zzdir on test2.zip using just 'test2' """ |
| 554 |
zipfile = "test2.zip" |
| 555 |
getfile = "test2" |
| 556 |
exe = self.bins("zzdir") |
| 557 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 558 |
self.assertIn(' file.01\n', run.output) |
| 559 |
self.assertIn(' file.22\n', run.output) |
| 560 |
self.assertIn(' file.99\n', run.output) |
| 561 |
self.assertIn(' defl:N ', run.output) |
| 562 |
self.assertIn(' stored ', run.output) |
| 563 |
def test_20023_zzdir_test3_zip(self): |
| 564 |
""" run zzdir on test3.zip using just 'test3' """ |
| 565 |
zipfile = "test3.zip" |
| 566 |
getfile = "test3" |
| 567 |
exe = self.bins("zzdir") |
| 568 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 569 |
self.assertIn(' file.001\n', run.output) |
| 570 |
self.assertIn(' file.222\n', run.output) |
| 571 |
self.assertIn(' file.999\n', run.output) |
| 572 |
self.assertIn(' defl:N ', run.output) |
| 573 |
self.assertIn(' stored ', run.output) |
| 574 |
def test_20024_zzdir_test4_zip(self): |
| 575 |
""" run zzdir on test4.zip using just 'test4' """ |
| 576 |
zipfile = "test4.zip" |
| 577 |
getfile = "test4" |
| 578 |
exe = self.bins("zzdir") |
| 579 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 580 |
self.assertIn(' file0001.txt\n', run.output) |
| 581 |
self.assertIn(' file2222.txt\n', run.output) |
| 582 |
self.assertIn(' file9999.txt\n', run.output) |
| 583 |
self.assertNotIn(' defl:N ', run.output) |
| 584 |
self.assertIn(' stored ', run.output) |
| 585 |
def test_20320_zzxordir_test0_dat(self): |
| 586 |
""" run zzxordir on test0x.dat """ |
| 587 |
zipfile = "test0x.dat" |
| 588 |
getfile = "test0x.dat" |
| 589 |
exe = self.bins("zzdir") |
| 590 |
run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1]) |
| 591 |
self.assertEqual(run.returncode, 1) |
| 592 |
self.assertEqual("", run.output) |
| 593 |
self.assertIn("did not open test", run.errors) |
| 594 |
exe = self.bins("zzxordir") |
| 595 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 596 |
self.assertIn(' README\n', run.output) |
| 597 |
self.assertIn(' defl:N ', run.output) |
| 598 |
self.assertLess(len(run.output), 30) |
| 599 |
def test_20321_zzxordir_test1_dat(self): |
| 600 |
""" run zzxordir on test1x.dat using just 'test1x' """ |
| 601 |
zipfile = "test1x.dat" |
| 602 |
getfile = "test1x.dat" |
| 603 |
exe = self.bins("zzdir") |
| 604 |
run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1]) |
| 605 |
self.assertEqual(run.returncode, 1) |
| 606 |
self.assertEqual("", run.output) |
| 607 |
self.assertIn("did not open test", run.errors) |
| 608 |
exe = self.bins("zzxordir") |
| 609 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 610 |
self.assertIn(' file.1\n', run.output) |
| 611 |
self.assertIn(' file.2\n', run.output) |
| 612 |
self.assertIn(' file.9\n', run.output) |
| 613 |
self.assertIn(' README\n', run.output) |
| 614 |
self.assertIn(' defl:N ', run.output) |
| 615 |
self.assertIn(' stored ', run.output) |
| 616 |
def test_20322_zzxordir_test2_dat(self): |
| 617 |
""" run zzxordir on test2x.dat using just 'test2x' """ |
| 618 |
zipfile = "test2x.dat" |
| 619 |
getfile = "test2x" |
| 620 |
exe = self.bins("zzdir") |
| 621 |
run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1]) |
| 622 |
self.assertEqual(run.returncode, 1) |
| 623 |
self.assertEqual("", run.output) |
| 624 |
self.assertIn("did not open test", run.errors) |
| 625 |
exe = self.bins("zzxordir") |
| 626 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 627 |
self.assertIn(' file.01\n', run.output) |
| 628 |
self.assertIn(' file.22\n', run.output) |
| 629 |
self.assertIn(' file.99\n', run.output) |
| 630 |
self.assertIn(' defl:N ', run.output) |
| 631 |
self.assertIn(' stored ', run.output) |
| 632 |
def test_20323_zzxordir_test3_dat(self): |
| 633 |
""" run zzxordir on test3x.dat using just 'test3x' """ |
| 634 |
zipfile = "test3x.dat" |
| 635 |
getfile = "test3x" |
| 636 |
exe = self.bins("zzdir") |
| 637 |
run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1]) |
| 638 |
self.assertEqual(run.returncode, 1) |
| 639 |
self.assertEqual("", run.output) |
| 640 |
self.assertIn("did not open test", run.errors) |
| 641 |
exe = self.bins("zzxordir") |
| 642 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 643 |
self.assertIn(' file.001\n', run.output) |
| 644 |
self.assertIn(' file.222\n', run.output) |
| 645 |
self.assertIn(' file.999\n', run.output) |
| 646 |
self.assertIn(' defl:N ', run.output) |
| 647 |
self.assertIn(' stored ', run.output) |
| 648 |
def test_20324_zzxordir_test4_zip(self): |
| 649 |
""" run zzxordir on test4x.dat using just 'test4x' """ |
| 650 |
zipfile = "test4x.dat" |
| 651 |
getfile = "test4x" |
| 652 |
exe = self.bins("zzdir") |
| 653 |
run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1]) |
| 654 |
self.assertEqual(run.returncode, 1) |
| 655 |
self.assertEqual("", run.output) |
| 656 |
self.assertIn("did not open test", run.errors) |
| 657 |
exe = self.bins("zzxordir") |
| 658 |
run = shell("{exe} {getfile} ".format(**locals())) |
| 659 |
self.assertIn(' file0001.txt\n', run.output) |
| 660 |
self.assertIn(' file2222.txt\n', run.output) |
| 661 |
self.assertIn(' file9999.txt\n', run.output) |
| 662 |
self.assertNotIn(' defl:N ', run.output) |
| 663 |
self.assertIn(' stored ', run.output) |
| 664 |
def test_20340_zzxorcat_test0_zip(self): |
| 665 |
""" run zzxorcat on testx.zip using just testx/README """ |
| 666 |
getfile = "test0x/README" |
| 667 |
logfile = "test0x.readme.txt" |
| 668 |
exe = self.bins("zzcat") |
| 669 |
run = shell("{exe} {getfile} ".format(**locals()), lang="C") |
| 670 |
self.assertEqual("", run.output) |
| 671 |
self.assertIn("No such file or directory", run.errors) |
| 672 |
exe = self.bins("zzxorcat") |
| 673 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 674 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 675 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 676 |
def test_20341_zzxorcat_test1_zip(self): |
| 677 |
""" run zzxorcat on testx.zip using just testx/README """ |
| 678 |
getfile = "test1x/README" |
| 679 |
logfile = "test1x.readme.txt" |
| 680 |
exe = self.bins("zzcat") |
| 681 |
run = shell("{exe} {getfile} ".format(**locals()), lang="C") |
| 682 |
self.assertEqual("", run.output) |
| 683 |
self.assertIn("No such file or directory", run.errors) |
| 684 |
exe = self.bins("zzxorcat") |
| 685 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 686 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 687 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 688 |
getfile = "test1x/file.1" |
| 689 |
run = shell("{exe} {getfile}".format(**locals())) |
| 690 |
self.assertEqual("file-1\n", run.output) |
| 691 |
def test_20342_zzxorcat_test2_zip(self): |
| 692 |
""" run zzxorcat on testx.zip using just testx/README """ |
| 693 |
getfile = "test2x/README" |
| 694 |
logfile = "test2x.readme.txt" |
| 695 |
exe = self.bins("zzcat") |
| 696 |
run = shell("{exe} {getfile} ".format(**locals()), lang="C") |
| 697 |
self.assertEqual("", run.output) |
| 698 |
self.assertIn("No such file or directory", run.errors) |
| 699 |
exe = self.bins("zzxorcat") |
| 700 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 701 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 702 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 703 |
getfile = "test2x/file.22" |
| 704 |
run = shell("{exe} {getfile}".format(**locals())) |
| 705 |
self.assertEqual("file-22\n", run.output) |
| 706 |
def test_20343_zzxorcat_test3_zip(self): |
| 707 |
""" run zzxorcat on testx.zip using just testx/README """ |
| 708 |
getfile = "test3x/README" |
| 709 |
logfile = "test3x.readme.txt" |
| 710 |
exe = self.bins("zzcat") |
| 711 |
run = shell("{exe} {getfile} ".format(**locals()), lang="C") |
| 712 |
self.assertEqual("", run.output) |
| 713 |
self.assertIn("No such file or directory", run.errors) |
| 714 |
exe = self.bins("zzxorcat") |
| 715 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 716 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 717 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 718 |
getfile = "test3x/file.999" |
| 719 |
run = shell("{exe} {getfile}".format(**locals())) |
| 720 |
self.assertEqual("file-999\n", run.output) |
| 721 |
def test_20344_zzxorcat_test4_zip(self): |
| 722 |
""" run zzxorcat on testx.zip using just testx/README """ |
| 723 |
getfile = "test4x/README" |
| 724 |
logfile = "test4x.readme.txt" |
| 725 |
exe = self.bins("zzxorcat") |
| 726 |
run = shell("{exe} {getfile} | tee {logfile}".format(**locals())) |
| 727 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 728 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 729 |
getfile = "test4x/file9999.txt" |
| 730 |
run = shell("{exe} {getfile}".format(**locals())) |
| 731 |
self.assertEqual("file-9999\n", run.output) |
| 732 |
##################################################################### |
| 733 |
# check unzzip |
| 734 |
##################################################################### |
| 735 |
def test_20400_infozip_cat_test0_zip(self): |
| 736 |
""" run inzo-zip cat test.zip using just archive README """ |
| 737 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 738 |
zipfile = "test0.zip" |
| 739 |
getfile = "README" |
| 740 |
logfile = "test0.readme.pk.txt" |
| 741 |
exe = self.bins("unzip") |
| 742 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 743 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 744 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 745 |
def test_20401_infozip_cat_test1_zip(self): |
| 746 |
""" run info-zip cat test.zip using just archive README """ |
| 747 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 748 |
zipfile = "test1.zip" |
| 749 |
getfile = "README" |
| 750 |
logfile = "test1.readme.pk.txt" |
| 751 |
exe = self.bins("unzip") |
| 752 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 753 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 754 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 755 |
getfile = "file.1" |
| 756 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 757 |
self.assertEqual("file-1\n", run.output) |
| 758 |
def test_20402_infozip_cat_test2_zip(self): |
| 759 |
""" run info-zip cat test.zip using just archive README """ |
| 760 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 761 |
zipfile = "test2.zip" |
| 762 |
getfile = "README" |
| 763 |
logfile = "test2.readme.pk.txt" |
| 764 |
exe = self.bins("unzip") |
| 765 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 766 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 767 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 768 |
getfile = "file.22" |
| 769 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 770 |
self.assertEqual("file-22\n", run.output) |
| 771 |
def test_20405_zzcat_big_test5_zip(self): |
| 772 |
""" run info-zip cat test.zip using archive README """ |
| 773 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 774 |
zipfile = "test5.zip" |
| 775 |
getfile = "README" |
| 776 |
logfile = "test5.readme.pk.txt" |
| 777 |
exe = self.bins("unzip") |
| 778 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 779 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 780 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 781 |
getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt" |
| 782 |
compare = self.gentext(1024) |
| 783 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 784 |
self.assertEqual(compare, run.output) |
| 785 |
def test_20410_zzcat_big_test0_zip(self): |
| 786 |
""" run zzcat-big on test.zip using just archive README """ |
| 787 |
zipfile = "test0.zip" |
| 788 |
getfile = "README" |
| 789 |
logfile = "test0.readme.big.txt" |
| 790 |
exe = self.bins("unzzip-big") |
| 791 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 792 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 793 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 794 |
def test_20411_zzcat_big_test1_zip(self): |
| 795 |
""" run zzcat-big on test.zip using just archive README """ |
| 796 |
zipfile = "test1.zip" |
| 797 |
getfile = "README" |
| 798 |
logfile = "test1.readme.big.txt" |
| 799 |
exe = self.bins("unzzip-big") |
| 800 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 801 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 802 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 803 |
getfile = "file.1" |
| 804 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 805 |
self.assertEqual("file-1\n", run.output) |
| 806 |
def test_20412_zzcat_big_test2_zip(self): |
| 807 |
""" run zzcat-seeke on test.zip using just archive README """ |
| 808 |
zipfile = "test2.zip" |
| 809 |
getfile = "README" |
| 810 |
logfile = "test2.readme.big.txt" |
| 811 |
exe = self.bins("unzzip-big") |
| 812 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 813 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 814 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 815 |
getfile = "file.22" |
| 816 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 817 |
self.assertEqual("file-22\n", run.output) |
| 818 |
def test_20415_zzcat_big_test5_zip(self): |
| 819 |
""" run zzcat-big on test.zip using archive README """ |
| 820 |
zipfile = "test5.zip" |
| 821 |
getfile = "README" |
| 822 |
logfile = "test5.readme.zap.txt" |
| 823 |
exe = self.bins("unzzip-big") |
| 824 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 825 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 826 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 827 |
getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt" |
| 828 |
compare = self.gentext(1024) |
| 829 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 830 |
self.assertEqual(compare, run.output) |
| 831 |
def test_20420_zzcat_mem_test0_zip(self): |
| 832 |
""" run zzcat-mem on test.zip using just archive README """ |
| 833 |
zipfile = "test0.zip" |
| 834 |
getfile = "README" |
| 835 |
logfile = "test0.readme.mem.txt" |
| 836 |
exe = self.bins("unzzip-mem") |
| 837 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 838 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 839 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 840 |
def test_20421_zzcat_mem_test1_zip(self): |
| 841 |
""" run zzcat-mem on test.zip using archive README """ |
| 842 |
zipfile = "test1.zip" |
| 843 |
getfile = "README" |
| 844 |
logfile = "test1.readme.mem.txt" |
| 845 |
exe = self.bins("unzzip-mem") |
| 846 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 847 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 848 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 849 |
getfile = "file.1" |
| 850 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 851 |
self.assertEqual("file-1\n", run.output) |
| 852 |
def test_20422_zzcat_mem_test2_zip(self): |
| 853 |
""" run zzcat-mem on test.zip using archive README """ |
| 854 |
zipfile = "test2.zip" |
| 855 |
getfile = "README" |
| 856 |
logfile = "test2.readme.mem.txt" |
| 857 |
exe = self.bins("unzzip-mem") |
| 858 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 859 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 860 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 861 |
getfile = "file.22" |
| 862 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 863 |
self.assertEqual("file-22\n", run.output) |
| 864 |
def test_20423_zzcat_mem_test3_zip(self): |
| 865 |
""" run zzcat-mem on test.zip using archive README """ |
| 866 |
zipfile = "test3.zip" |
| 867 |
getfile = "README" |
| 868 |
logfile = "test3.readme.mem.txt" |
| 869 |
exe = self.bins("unzzip-mem") |
| 870 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 871 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 872 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 873 |
getfile = "file.999" |
| 874 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 875 |
self.assertEqual("file-999\n", run.output) |
| 876 |
def test_20424_zzcat_mem_test4_zip(self): |
| 877 |
""" run zzcat-mem on test.zip using archive README """ |
| 878 |
zipfile = "test4.zip" |
| 879 |
getfile = "README" |
| 880 |
logfile = "test4.readme.mem.txt" |
| 881 |
exe = self.bins("unzzip-mem") |
| 882 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 883 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 884 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 885 |
getfile = "file9999.txt" |
| 886 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 887 |
self.assertEqual("file-9999\n", run.output) |
| 888 |
def test_20425_zzcat_mem_test5_zip(self): |
| 889 |
""" run zzcat-mem on test.zip using archive README """ |
| 890 |
zipfile = "test5.zip" |
| 891 |
getfile = "README" |
| 892 |
logfile = "test5.readme.zap.txt" |
| 893 |
exe = self.bins("unzzip-mem") |
| 894 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 895 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 896 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 897 |
getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt" |
| 898 |
compare = self.gentext(1024) |
| 899 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 900 |
self.assertEqual(compare, run.output) |
| 901 |
def test_20430_zzcat_mix_test0_zip(self): |
| 902 |
""" run zzcat-mix on test.zip using just archive README """ |
| 903 |
zipfile = "test0.zip" |
| 904 |
getfile = "README" |
| 905 |
logfile = "test0.readme.mix.txt" |
| 906 |
exe = self.bins("unzzip-mix") |
| 907 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 908 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 909 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 910 |
def test_20431_zzcat_mix_test1_zip(self): |
| 911 |
""" run zzcat-mix on test.zip using archive README """ |
| 912 |
zipfile = "test1.zip" |
| 913 |
getfile = "README" |
| 914 |
logfile = "test1.readme.mix.txt" |
| 915 |
exe = self.bins("unzzip-mix") |
| 916 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 917 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 918 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 919 |
getfile = "file.1" |
| 920 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 921 |
self.assertEqual("file-1\n", run.output) |
| 922 |
def test_20432_zzcat_mix_test2_zip(self): |
| 923 |
""" run zzcat-mix on test.zip using archive README """ |
| 924 |
zipfile = "test2.zip" |
| 925 |
getfile = "README" |
| 926 |
logfile = "test2.readme.mix.txt" |
| 927 |
exe = self.bins("unzzip-mix") |
| 928 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 929 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 930 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 931 |
getfile = "file.22" |
| 932 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 933 |
self.assertEqual("file-22\n", run.output) |
| 934 |
def test_20433_zzcat_mix_test3_zip(self): |
| 935 |
""" run zzcat-mix on test.zip using archive README """ |
| 936 |
zipfile = "test3.zip" |
| 937 |
getfile = "README" |
| 938 |
logfile = "test3.readme.mix.txt" |
| 939 |
exe = self.bins("unzzip-mix") |
| 940 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 941 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 942 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 943 |
getfile = "file.999" |
| 944 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 945 |
self.assertEqual("file-999\n", run.output) |
| 946 |
def test_20434_zzcat_mix_test4_zip(self): |
| 947 |
""" run zzcat-mix on test.zip using archive README """ |
| 948 |
zipfile = "test4.zip" |
| 949 |
getfile = "README" |
| 950 |
logfile = "test4.readme.mix.txt" |
| 951 |
exe = self.bins("unzzip-mix") |
| 952 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 953 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 954 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 955 |
getfile = "file9999.txt" |
| 956 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 957 |
self.assertEqual("file-9999\n", run.output) |
| 958 |
def test_20435_zzcat_mix_test5_zip(self): |
| 959 |
""" run zzcat-mix on test.zip using archive README """ |
| 960 |
zipfile = "test5.zip" |
| 961 |
getfile = "README" |
| 962 |
logfile = "test5.readme.zap.txt" |
| 963 |
exe = self.bins("unzzip-mix") |
| 964 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 965 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 966 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 967 |
getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt" |
| 968 |
compare = self.gentext(1024) |
| 969 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 970 |
self.assertEqual(compare, run.output) |
| 971 |
def test_20440_zzcat_zap_test0_zip(self): |
| 972 |
""" run zzcat-zap on test.zip using just archive README """ |
| 973 |
zipfile = "test0.zip" |
| 974 |
getfile = "README" |
| 975 |
logfile = "test0.readme.txt" |
| 976 |
exe = self.bins("unzzip") |
| 977 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 978 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 979 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 980 |
def test_20441_zzcat_zap_test1_zip(self): |
| 981 |
""" run zzcat-zap on test.zip using archive README """ |
| 982 |
zipfile = "test1.zip" |
| 983 |
getfile = "README" |
| 984 |
logfile = "test1.readme.zap.txt" |
| 985 |
exe = self.bins("unzzip") |
| 986 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 987 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 988 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 989 |
getfile = "file.1" |
| 990 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 991 |
self.assertEqual("file-1\n", run.output) |
| 992 |
def test_20442_zzcat_zap_test2_zip(self): |
| 993 |
""" run zzcat-zap on test.zip using archive README """ |
| 994 |
zipfile = "test2.zip" |
| 995 |
getfile = "README" |
| 996 |
logfile = "test2.readme.zap.txt" |
| 997 |
exe = self.bins("unzzip") |
| 998 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 999 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 1000 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 1001 |
getfile = "file.22" |
| 1002 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 1003 |
self.assertEqual("file-22\n", run.output) |
| 1004 |
def test_20443_zzcat_zap_test3_zip(self): |
| 1005 |
""" run zzcat-zap on test.zip using archive README """ |
| 1006 |
zipfile = "test3.zip" |
| 1007 |
getfile = "README" |
| 1008 |
logfile = "test3.readme.zap.txt" |
| 1009 |
exe = self.bins("unzzip") |
| 1010 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 1011 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 1012 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 1013 |
getfile = "file.999" |
| 1014 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 1015 |
self.assertEqual("file-999\n", run.output) |
| 1016 |
def test_20444_zzcat_zap_test4_zip(self): |
| 1017 |
""" run zzcat-zap on test.zip using archive README """ |
| 1018 |
zipfile = "test4.zip" |
| 1019 |
getfile = "README" |
| 1020 |
logfile = "test4.readme.zap.txt" |
| 1021 |
exe = self.bins("unzzip") |
| 1022 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 1023 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 1024 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 1025 |
getfile = "file9999.txt" |
| 1026 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 1027 |
self.assertEqual("file-9999\n", run.output) |
| 1028 |
def test_20445_zzcat_zap_test5_zip(self): |
| 1029 |
""" run zzcat-zap on test.zip using archive README """ |
| 1030 |
zipfile = "test5.zip" |
| 1031 |
getfile = "README" |
| 1032 |
logfile = "test5.readme.zap.txt" |
| 1033 |
exe = self.bins("unzzip") |
| 1034 |
run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals())) |
| 1035 |
self.assertGreater(os.path.getsize(logfile), 10) |
| 1036 |
self.assertEqual(run.output.split("\n"), self.readme().split("\n")) |
| 1037 |
getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt" |
| 1038 |
compare = self.gentext(1024) |
| 1039 |
run = shell("{exe} -p {zipfile} {getfile}".format(**locals())) |
| 1040 |
self.assertEqual(compare, run.output) |
| 1041 |
|
| 1042 |
def test_20500_infozipdir_test0_zip(self): |
| 1043 |
""" run info-zip dir test0.zip """ |
| 1044 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1045 |
zipfile = "test0.zip" |
| 1046 |
getfile = "test0.zip" |
| 1047 |
exe = self.bins("unzip") |
| 1048 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1049 |
self.assertIn(' README\n', run.output) |
| 1050 |
self.assertLess(len(run.output), 230) |
| 1051 |
def test_20501_infozipdir_test1_zip(self): |
| 1052 |
""" run info-zip dir test1.zip """ |
| 1053 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1054 |
zipfile = "test1.zip" |
| 1055 |
getfile = "test1.zip" |
| 1056 |
exe = self.bins("unzip") |
| 1057 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1058 |
self.assertIn(' file.1\n', run.output) |
| 1059 |
self.assertIn(' file.2\n', run.output) |
| 1060 |
self.assertIn(' file.9\n', run.output) |
| 1061 |
self.assertIn(' README\n', run.output) |
| 1062 |
def test_20502_infozipdir_big_test2_zip(self): |
| 1063 |
""" run info-zip dir test2.zip """ |
| 1064 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1065 |
zipfile = "test2.zip" |
| 1066 |
getfile = "test2.zip" |
| 1067 |
exe = self.bins("unzip") |
| 1068 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1069 |
self.assertIn(' file.01\n', run.output) |
| 1070 |
self.assertIn(' file.22\n', run.output) |
| 1071 |
self.assertIn(' file.99\n', run.output) |
| 1072 |
def test_20503_infozipdir_big_test3_zip(self): |
| 1073 |
""" run info-zip dir test3.zip """ |
| 1074 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1075 |
zipfile = "test3.zip" |
| 1076 |
getfile = "test3.zip" |
| 1077 |
exe = self.bins("unzip") |
| 1078 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1079 |
self.assertIn(' file.001\n', run.output) |
| 1080 |
self.assertIn(' file.222\n', run.output) |
| 1081 |
self.assertIn(' file.999\n', run.output) |
| 1082 |
def test_20504_infozipdir_big_test4_zip(self): |
| 1083 |
""" run info-zip dir test4.zip """ |
| 1084 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1085 |
zipfile = "test4.zip" |
| 1086 |
getfile = "test4.zip" |
| 1087 |
exe = self.bins("unzip") |
| 1088 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1089 |
self.assertIn(' file0001.txt\n', run.output) |
| 1090 |
self.assertIn(' file2222.txt\n', run.output) |
| 1091 |
self.assertIn(' file9999.txt\n', run.output) |
| 1092 |
def test_20505_infozipdir_big_test5_zip(self): |
| 1093 |
""" run info-zip dir on test5.zip """ |
| 1094 |
zipfile = "test5.zip" |
| 1095 |
getfile = "test5.zip" |
| 1096 |
exe = self.bins("unzzip-mix") |
| 1097 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1098 |
self.assertIn('/subdir14/file15-128.txt\n', run.output) |
| 1099 |
self.assertIn('/subdir5/subdir6/', run.output) |
| 1100 |
self.assertIn(' defl:N ', run.output) |
| 1101 |
self.assertIn(' stored ', run.output) |
| 1102 |
def test_20510_zzdir_big_test0_zip(self): |
| 1103 |
""" run zzdir-big on test0.zip """ |
| 1104 |
zipfile = "test0.zip" |
| 1105 |
getfile = "test0.zip" |
| 1106 |
exe = self.bins("unzzip-big") |
| 1107 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1108 |
self.assertIn(' README\n', run.output) |
| 1109 |
self.assertLess(len(run.output), 30) |
| 1110 |
def test_20511_zzdir_big_test1_zip(self): |
| 1111 |
""" run zzdir-big on test1.zip """ |
| 1112 |
zipfile = "test1.zip" |
| 1113 |
getfile = "test1.zip" |
| 1114 |
exe = self.bins("unzzip-big") |
| 1115 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1116 |
self.assertIn(' file.1\n', run.output) |
| 1117 |
self.assertIn(' file.2\n', run.output) |
| 1118 |
self.assertIn(' file.9\n', run.output) |
| 1119 |
self.assertIn(' README\n', run.output) |
| 1120 |
def test_20512_zzdir_big_test2_zip(self): |
| 1121 |
""" run zzdir-big on test2.zip """ |
| 1122 |
zipfile = "test2.zip" |
| 1123 |
getfile = "test2.zip" |
| 1124 |
exe = self.bins("unzzip-big") |
| 1125 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1126 |
self.assertIn(' file.01\n', run.output) |
| 1127 |
self.assertIn(' file.22\n', run.output) |
| 1128 |
self.assertIn(' file.99\n', run.output) |
| 1129 |
def test_20513_zzdir_big_test3_zip(self): |
| 1130 |
""" run zzdir-big on test3.zip """ |
| 1131 |
zipfile = "test3.zip" |
| 1132 |
getfile = "test3.zip" |
| 1133 |
exe = self.bins("unzzip-big") |
| 1134 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1135 |
self.assertIn(' file.001\n', run.output) |
| 1136 |
self.assertIn(' file.222\n', run.output) |
| 1137 |
self.assertIn(' file.999\n', run.output) |
| 1138 |
def test_20514_zzdir_big_test4_zip(self): |
| 1139 |
""" run zzdir-big on test4.zip """ |
| 1140 |
zipfile = "test4.zip" |
| 1141 |
getfile = "test4.zip" |
| 1142 |
exe = self.bins("unzzip-big") |
| 1143 |
run = shell("{exe} -l {getfile} ".format(**locals())) |
| 1144 |
self.assertIn(' file0001.txt\n', run.output) |
| 1145 |
self.assertIn(' file2222.txt\n', run.output) |
| 1146 |
self.assertIn(' file9999.txt\n', run.output) |
| 1147 |
def test_20515_zzdir_big_test5_zip(self): |
| 1148 |
""" run zzdir-big on test5.zip """ |
| 1149 |
zipfile = "test5.zip" |
| 1150 |
getfile = "test5.zip" |
| 1151 |
exe = self.bins("unzzip-mix") |
| 1152 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1153 |
self.assertIn('/subdir14/file15-128.txt\n', run.output) |
| 1154 |
self.assertIn('/subdir5/subdir6/', run.output) |
| 1155 |
self.assertIn(' defl:N ', run.output) |
| 1156 |
self.assertIn(' stored ', run.output) |
| 1157 |
def test_20520_zzdir_mem_test0_zip(self): |
| 1158 |
""" run zzdir-mem on test0.zip """ |
| 1159 |
zipfile = "test0.zip" |
| 1160 |
getfile = "test0.zip" |
| 1161 |
exe = self.bins("unzzip-mem") |
| 1162 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1163 |
self.assertIn(' README\n', run.output) |
| 1164 |
self.assertIn(' defl:N ', run.output) |
| 1165 |
self.assertLess(len(run.output), 30) |
| 1166 |
def test_20521_zzdir_mem_test1_zip(self): |
| 1167 |
""" run zzdir-mem on test1.zip """ |
| 1168 |
zipfile = "test1.zip" |
| 1169 |
getfile = "test1.zip" |
| 1170 |
exe = self.bins("unzzip-mem") |
| 1171 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1172 |
self.assertIn(' file.1\n', run.output) |
| 1173 |
self.assertIn(' file.2\n', run.output) |
| 1174 |
self.assertIn(' file.9\n', run.output) |
| 1175 |
self.assertIn(' README\n', run.output) |
| 1176 |
self.assertIn(' defl:N ', run.output) |
| 1177 |
self.assertIn(' stored ', run.output) |
| 1178 |
def test_20522_zzdir_mem_test2_zip(self): |
| 1179 |
""" run zzdir-mem on test2.zip """ |
| 1180 |
zipfile = "test2.zip" |
| 1181 |
getfile = "test2.zip" |
| 1182 |
exe = self.bins("unzzip-mem") |
| 1183 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1184 |
self.assertIn(' file.01\n', run.output) |
| 1185 |
self.assertIn(' file.22\n', run.output) |
| 1186 |
self.assertIn(' file.99\n', run.output) |
| 1187 |
self.assertIn(' defl:N ', run.output) |
| 1188 |
self.assertIn(' stored ', run.output) |
| 1189 |
def test_20523_zzdir_mem_test3_zip(self): |
| 1190 |
""" run zzdir-mem on test3.zip """ |
| 1191 |
zipfile = "test3.zip" |
| 1192 |
getfile = "test3.zip" |
| 1193 |
exe = self.bins("unzzip-mem") |
| 1194 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1195 |
self.assertIn(' file.001\n', run.output) |
| 1196 |
self.assertIn(' file.222\n', run.output) |
| 1197 |
self.assertIn(' file.999\n', run.output) |
| 1198 |
self.assertIn(' defl:N ', run.output) |
| 1199 |
self.assertIn(' stored ', run.output) |
| 1200 |
def test_20524_zzdir_mem_test4_zip(self): |
| 1201 |
""" run zzdir-mem on test4.zip """ |
| 1202 |
zipfile = "test4.zip" |
| 1203 |
getfile = "test4.zip" |
| 1204 |
exe = self.bins("unzzip-mem") |
| 1205 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1206 |
self.assertIn(' file0001.txt\n', run.output) |
| 1207 |
self.assertIn(' file2222.txt\n', run.output) |
| 1208 |
self.assertIn(' file9999.txt\n', run.output) |
| 1209 |
self.assertNotIn(' defl:N ', run.output) |
| 1210 |
self.assertIn(' stored ', run.output) |
| 1211 |
def test_20525_zzdir_mem_test5_zip(self): |
| 1212 |
""" run zzdir-mem on test5.zip """ |
| 1213 |
zipfile = "test5.zip" |
| 1214 |
getfile = "test5.zip" |
| 1215 |
exe = self.bins("unzzip-mix") |
| 1216 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1217 |
self.assertIn('/subdir14/file15-128.txt\n', run.output) |
| 1218 |
self.assertIn('/subdir5/subdir6/', run.output) |
| 1219 |
self.assertIn(' defl:N ', run.output) |
| 1220 |
self.assertIn(' stored ', run.output) |
| 1221 |
def test_20530_zzdir_mix_test0_zip(self): |
| 1222 |
""" run zzdir-mix on test0.zip """ |
| 1223 |
# self.skipTest("todo") |
| 1224 |
zipfile = "test0.zip" |
| 1225 |
getfile = "test0.zip" |
| 1226 |
exe = self.bins("unzzip-mix") |
| 1227 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1228 |
self.assertIn(' README\n', run.output) |
| 1229 |
self.assertIn(' defl:N ', run.output) |
| 1230 |
self.assertLess(len(run.output), 30) |
| 1231 |
def test_20531_zzdir_mix_test1_zip(self): |
| 1232 |
""" run zzdir-mix on test1.zip """ |
| 1233 |
zipfile = "test1.zip" |
| 1234 |
getfile = "test1.zip" |
| 1235 |
exe = self.bins("unzzip-mix") |
| 1236 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1237 |
self.assertIn(' file.1\n', run.output) |
| 1238 |
self.assertIn(' file.2\n', run.output) |
| 1239 |
self.assertIn(' file.9\n', run.output) |
| 1240 |
self.assertIn(' README\n', run.output) |
| 1241 |
self.assertIn(' defl:N ', run.output) |
| 1242 |
self.assertIn(' stored ', run.output) |
| 1243 |
def test_20532_zzdir_mix_test2_zip(self): |
| 1244 |
""" run zzdir-mix on test2.zip """ |
| 1245 |
zipfile = "test2.zip" |
| 1246 |
getfile = "test2.zip" |
| 1247 |
exe = self.bins("unzzip-mix") |
| 1248 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1249 |
self.assertIn(' file.01\n', run.output) |
| 1250 |
self.assertIn(' file.22\n', run.output) |
| 1251 |
self.assertIn(' file.99\n', run.output) |
| 1252 |
self.assertIn(' defl:N ', run.output) |
| 1253 |
self.assertIn(' stored ', run.output) |
| 1254 |
def test_20533_zzdir_mix_test3_zip(self): |
| 1255 |
""" run zzdir-mix on test3.zip """ |
| 1256 |
zipfile = "test3.zip" |
| 1257 |
getfile = "test3.zip" |
| 1258 |
exe = self.bins("unzzip-mix") |
| 1259 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1260 |
self.assertIn(' file.001\n', run.output) |
| 1261 |
self.assertIn(' file.222\n', run.output) |
| 1262 |
self.assertIn(' file.999\n', run.output) |
| 1263 |
self.assertIn(' defl:N ', run.output) |
| 1264 |
self.assertIn(' stored ', run.output) |
| 1265 |
def test_20534_zzdir_mix_test4_zip(self): |
| 1266 |
""" run zzdir-mix on test4.zip """ |
| 1267 |
zipfile = "test4.zip" |
| 1268 |
getfile = "test4.zip" |
| 1269 |
exe = self.bins("unzzip-mix") |
| 1270 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1271 |
self.assertIn(' file0001.txt\n', run.output) |
| 1272 |
self.assertIn(' file2222.txt\n', run.output) |
| 1273 |
self.assertIn(' file9999.txt\n', run.output) |
| 1274 |
self.assertNotIn(' defl:N ', run.output) |
| 1275 |
self.assertIn(' stored ', run.output) |
| 1276 |
def test_20535_zzdir_mix_test5_zip(self): |
| 1277 |
""" run zzdir-mix on test5.zip """ |
| 1278 |
zipfile = "test5.zip" |
| 1279 |
getfile = "test5.zip" |
| 1280 |
exe = self.bins("unzzip-mix") |
| 1281 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1282 |
self.assertIn('/subdir14/file15-128.txt\n', run.output) |
| 1283 |
self.assertIn('/subdir5/subdir6/', run.output) |
| 1284 |
self.assertIn(' defl:N ', run.output) |
| 1285 |
self.assertIn(' stored ', run.output) |
| 1286 |
def test_20540_zzdir_zap_test0_zip(self): |
| 1287 |
""" run zzdir-zap on test0.zip """ |
| 1288 |
zipfile = "test0.zip" |
| 1289 |
getfile = "test0.zip" |
| 1290 |
exe = self.bins("unzzip") |
| 1291 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1292 |
self.assertIn(' README\n', run.output) |
| 1293 |
self.assertIn(' defl:N ', run.output) |
| 1294 |
self.assertLess(len(run.output), 30) |
| 1295 |
def test_20541_zzdir_zap_test1_zip(self): |
| 1296 |
""" run zzdir-zap on test1.zip """ |
| 1297 |
zipfile = "test1.zip" |
| 1298 |
getfile = "test1.zip" |
| 1299 |
exe = self.bins("unzzip") |
| 1300 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1301 |
self.assertIn(' file.1\n', run.output) |
| 1302 |
self.assertIn(' file.2\n', run.output) |
| 1303 |
self.assertIn(' file.9\n', run.output) |
| 1304 |
self.assertIn(' README\n', run.output) |
| 1305 |
self.assertIn(' defl:N ', run.output) |
| 1306 |
self.assertIn(' stored ', run.output) |
| 1307 |
def test_20542_zzdir_zap_test2_zip(self): |
| 1308 |
""" run zzdir-zap on test2.zip """ |
| 1309 |
zipfile = "test2.zip" |
| 1310 |
getfile = "test2.zip" |
| 1311 |
exe = self.bins("unzzip") |
| 1312 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1313 |
self.assertIn(' file.01\n', run.output) |
| 1314 |
self.assertIn(' file.22\n', run.output) |
| 1315 |
self.assertIn(' file.99\n', run.output) |
| 1316 |
self.assertIn(' defl:N ', run.output) |
| 1317 |
self.assertIn(' stored ', run.output) |
| 1318 |
def test_20543_zzdir_zap_test3_zip(self): |
| 1319 |
""" run zzdir-zap on test3.zip """ |
| 1320 |
zipfile = "test3.zip" |
| 1321 |
getfile = "test3.zip" |
| 1322 |
exe = self.bins("unzzip") |
| 1323 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1324 |
self.assertIn(' file.001\n', run.output) |
| 1325 |
self.assertIn(' file.222\n', run.output) |
| 1326 |
self.assertIn(' file.999\n', run.output) |
| 1327 |
self.assertIn(' defl:N ', run.output) |
| 1328 |
self.assertIn(' stored ', run.output) |
| 1329 |
def test_20544_zzdir_zap_test4_zip(self): |
| 1330 |
""" run zzdir-zap on test4.zip """ |
| 1331 |
zipfile = "test4.zip" |
| 1332 |
getfile = "test4.zip" |
| 1333 |
exe = self.bins("unzzip") |
| 1334 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1335 |
self.assertIn(' file0001.txt\n', run.output) |
| 1336 |
self.assertIn(' file2222.txt\n', run.output) |
| 1337 |
self.assertIn(' file9999.txt\n', run.output) |
| 1338 |
self.assertNotIn(' defl:N ', run.output) |
| 1339 |
self.assertIn(' stored ', run.output) |
| 1340 |
def test_20545_zzdir_zap_test5_zip(self): |
| 1341 |
""" run zzdir-zap on test5.zip """ |
| 1342 |
zipfile = "test5.zip" |
| 1343 |
getfile = "test5.zip" |
| 1344 |
exe = self.bins("unzzip") |
| 1345 |
run = shell("{exe} -v {getfile} ".format(**locals())) |
| 1346 |
self.assertIn('/subdir14/file15-128.txt\n', run.output) |
| 1347 |
self.assertIn('/subdir5/subdir6/', run.output) |
| 1348 |
self.assertIn(' defl:N ', run.output) |
| 1349 |
self.assertIn(' stored ', run.output) |
| 1350 |
def test_20595_zzextract_zap_test5_zip(self): |
| 1351 |
""" run zzextract-zap on test5.zip |
| 1352 |
=> coughs up a SEGFAULT in zzip_dir_close() ?!?""" |
| 1353 |
self.rm_testdir() |
| 1354 |
zipfile = "test5.zip" |
| 1355 |
getfile = "test5.zip" |
| 1356 |
tmpdir = self.testdir() |
| 1357 |
exe = self.bins("unzzip") |
| 1358 |
run = shell("cd {tmpdir} && ../{exe} ../{getfile} ".format(**locals())); |
| 1359 |
self.assertTrue(tmpdir+'/subdir1/subdir2/file3-1024.txt') |
| 1360 |
# self.rm_testdir() |
| 1361 |
|
| 1362 |
url_CVE_2017_5977 = "https://github.com/asarubbo/poc/blob/master" |
| 1363 |
zip_CVE_2017_5977 = "00153-zziplib-invalidread-zzip_mem_entry_extra_block" |
| 1364 |
def test_59770_infozipdir_CVE_2017_5977(self): |
| 1365 |
""" run info-zip dir test0.zip """ |
| 1366 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1367 |
tmpdir = self.testdir() |
| 1368 |
filename = self.zip_CVE_2017_5977 |
| 1369 |
file_url = self.url_CVE_2017_5977 |
| 1370 |
if not download_raw(file_url, filename, tmpdir): |
| 1371 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1372 |
exe = self.bins("unzip") |
| 1373 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1374 |
returncodes = [0, 2]) |
| 1375 |
self.assertIn(" didn't find end-of-central-dir signature at end of central dir", run.errors) |
| 1376 |
self.assertIn(" 2 extra bytes at beginning or within zipfile", run.errors) |
| 1377 |
self.assertLess(len(run.output), 280) |
| 1378 |
# |
| 1379 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1380 |
returncodes = [2]) |
| 1381 |
self.assertLess(len(run.output), 101) |
| 1382 |
self.assertLess(len(errors(run.errors)), 900) |
| 1383 |
self.assertIn('test: mismatching "local" filename', run.errors) |
| 1384 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1385 |
self.rm_testdir() |
| 1386 |
def test_59771_zzipdir_big_CVE_2017_5977(self): |
| 1387 |
""" run info-zip -l $(CVE_2017_5977).zip """ |
| 1388 |
tmpdir = self.testdir() |
| 1389 |
filename = self.zip_CVE_2017_5977 |
| 1390 |
file_url = self.url_CVE_2017_5977 |
| 1391 |
if not download_raw(file_url, filename, tmpdir): |
| 1392 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1393 |
exe = self.bins("unzzip-big") |
| 1394 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1395 |
returncodes = [0]) |
| 1396 |
self.assertLess(len(run.output), 30) |
| 1397 |
self.assertLess(len(errors(run.errors)), 1) |
| 1398 |
self.assertIn(" stored test", run.output) |
| 1399 |
# |
| 1400 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1401 |
returncodes = [0]) |
| 1402 |
self.assertLess(len(run.output), 30) |
| 1403 |
self.assertLess(len(errors(run.errors)), 1) |
| 1404 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1405 |
self.rm_testdir() |
| 1406 |
def test_59772_zzipdir_mem_CVE_2017_5977(self): |
| 1407 |
""" run unzzip-mem -l $(CVE_2017_5977).zip """ |
| 1408 |
tmpdir = self.testdir() |
| 1409 |
filename = self.zip_CVE_2017_5977 |
| 1410 |
file_url = self.url_CVE_2017_5977 |
| 1411 |
if not download_raw(file_url, filename, tmpdir): |
| 1412 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1413 |
exe = self.bins("unzzip-mem") |
| 1414 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1415 |
returncodes = [0]) |
| 1416 |
self.assertLess(len(run.output), 30) |
| 1417 |
self.assertLess(len(errors(run.errors)), 1) |
| 1418 |
self.assertIn(" 3 test", run.output) |
| 1419 |
# |
| 1420 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1421 |
returncodes = [0]) |
| 1422 |
self.assertLess(len(run.output), 30) |
| 1423 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1424 |
self.rm_testdir() |
| 1425 |
def test_59773_zzipdir_mix_CVE_2017_5977(self): |
| 1426 |
""" run unzzip-mix -l $(CVE_2017_5977).zip """ |
| 1427 |
tmpdir = self.testdir() |
| 1428 |
filename = self.zip_CVE_2017_5977 |
| 1429 |
file_url = self.url_CVE_2017_5977 |
| 1430 |
if not download_raw(file_url, filename, tmpdir): |
| 1431 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1432 |
exe = self.bins("unzzip-mix") |
| 1433 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1434 |
returncodes = [0]) |
| 1435 |
self.assertLess(len(run.output), 30) |
| 1436 |
self.assertLess(len(errors(run.errors)), 1) |
| 1437 |
self.assertIn(" 3 test", run.output) |
| 1438 |
# |
| 1439 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1440 |
returncodes = [0]) |
| 1441 |
self.assertLess(len(run.output), 30) |
| 1442 |
self.assertLess(len(errors(run.errors)), 1) |
| 1443 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1444 |
self.rm_testdir() |
| 1445 |
def test_59774_zzipdir_zap_CVE_2017_5977(self): |
| 1446 |
""" run unzzip -l $(CVE_2017_5977).zip """ |
| 1447 |
tmpdir = self.testdir() |
| 1448 |
filename = self.zip_CVE_2017_5977 |
| 1449 |
file_url = self.url_CVE_2017_5977 |
| 1450 |
if not download_raw(file_url, filename, tmpdir): |
| 1451 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1452 |
exe = self.bins("unzzip") |
| 1453 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1454 |
returncodes = [0, 255]) |
| 1455 |
self.assertLess(len(run.output), 30) |
| 1456 |
self.assertLess(len(errors(run.errors)), 1) |
| 1457 |
self.assertIn(" 3 test", run.output) |
| 1458 |
# |
| 1459 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1460 |
returncodes = [0]) |
| 1461 |
self.assertLess(len(run.output), 30) |
| 1462 |
self.assertLess(len(errors(run.errors)), 1) |
| 1463 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) # TODO |
| 1464 |
self.rm_testdir() |
| 1465 |
def test_59779(self): |
| 1466 |
""" check $(CVE).zip """ |
| 1467 |
tmpdir = self.testdir() |
| 1468 |
filename = self.zip_CVE_2017_5977 |
| 1469 |
file_url = self.url_CVE_2017_5977 |
| 1470 |
if not download_raw(file_url, filename, tmpdir): |
| 1471 |
self.skipTest("no zip_CVE_2017_5977 available: " + filename) |
| 1472 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 1473 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 1474 |
self.assertEqual(size, 163) |
| 1475 |
|
| 1476 |
url_CVE_2017_5978 = "https://github.com/asarubbo/poc/blob/master" |
| 1477 |
zip_CVE_2017_5978 = "00156-zziplib-oobread-zzip_mem_entry_new" |
| 1478 |
def test_59780_infozipdir_CVE_2017_5978(self): |
| 1479 |
""" run info-zip dir test0.zip """ |
| 1480 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1481 |
tmpdir = self.testdir() |
| 1482 |
filename = self.zip_CVE_2017_5978 |
| 1483 |
file_url = self.url_CVE_2017_5978 |
| 1484 |
if not download_raw(file_url, filename, tmpdir): |
| 1485 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1486 |
exe = self.bins("unzip") |
| 1487 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1488 |
returncodes = [0, 3]) |
| 1489 |
self.assertIn(' missing 4608 bytes in zipfile', run.errors) |
| 1490 |
self.assertIn(' attempt to seek before beginning of zipfile', run.errors) |
| 1491 |
self.assertLess(len(run.output), 80) |
| 1492 |
self.assertLess(len(errors(run.errors)), 430) |
| 1493 |
# |
| 1494 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1495 |
returncodes = [3]) |
| 1496 |
self.assertLess(len(run.output), 90) |
| 1497 |
self.assertLess(len(errors(run.errors)), 900) |
| 1498 |
self.assertIn('attempt to seek before beginning of zipfile', run.errors) |
| 1499 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1500 |
self.rm_testdir() |
| 1501 |
def test_59781_zzipdir_big_CVE_2017_5978(self): |
| 1502 |
""" run info-zip -l $(CVE_2017_5978).zip """ |
| 1503 |
tmpdir = self.testdir() |
| 1504 |
filename = self.zip_CVE_2017_5978 |
| 1505 |
file_url = self.url_CVE_2017_5978 |
| 1506 |
if not download_raw(file_url, filename, tmpdir): |
| 1507 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1508 |
exe = self.bins("unzzip-big") |
| 1509 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1510 |
returncodes = [0]) |
| 1511 |
self.assertLess(len(run.output), 30) |
| 1512 |
self.assertLess(len(errors(run.errors)), 1) |
| 1513 |
self.assertIn(" stored (null)", run.output) |
| 1514 |
# |
| 1515 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1516 |
returncodes = [0,1]) |
| 1517 |
self.assertLess(len(run.output), 30) |
| 1518 |
self.assertLess(len(errors(run.errors)), 1) |
| 1519 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1520 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1521 |
self.rm_testdir() |
| 1522 |
def test_59782_zzipdir_mem_CVE_2017_5978(self): |
| 1523 |
""" run unzzip-mem -l $(CVE_2017_5978).zip """ |
| 1524 |
tmpdir = self.testdir() |
| 1525 |
filename = self.zip_CVE_2017_5978 |
| 1526 |
file_url = self.url_CVE_2017_5978 |
| 1527 |
if not download_raw(file_url, filename, tmpdir): |
| 1528 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1529 |
exe = self.bins("unzzip-mem") |
| 1530 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1531 |
returncodes = [0]) |
| 1532 |
self.assertLess(len(run.output), 1) |
| 1533 |
self.assertLess(len(errors(run.errors)), 180) |
| 1534 |
# self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors) |
| 1535 |
self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors) |
| 1536 |
# |
| 1537 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1538 |
returncodes = [0]) |
| 1539 |
self.assertLess(len(run.output), 30) |
| 1540 |
self.assertLess(len(errors(run.errors)), 300) |
| 1541 |
if grep("DEBUG:", run.errors): |
| 1542 |
self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors) |
| 1543 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1544 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1545 |
self.rm_testdir() |
| 1546 |
def test_59783_zzipdir_mix_CVE_2017_5978(self): |
| 1547 |
""" run unzzip-mix -l $(CVE_2017_5978).zip """ |
| 1548 |
tmpdir = self.testdir() |
| 1549 |
filename = self.zip_CVE_2017_5978 |
| 1550 |
file_url = self.url_CVE_2017_5978 |
| 1551 |
if not download_raw(file_url, filename, tmpdir): |
| 1552 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1553 |
exe = self.bins("unzzip-mix") |
| 1554 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1555 |
returncodes = [0,2]) |
| 1556 |
self.assertLess(len(run.output), 1) |
| 1557 |
self.assertLess(len(errors(run.errors)), 180) |
| 1558 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 1559 |
# |
| 1560 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1561 |
returncodes = [0,2]) |
| 1562 |
self.assertLess(len(run.output), 30) |
| 1563 |
self.assertLess(len(errors(run.errors)), 300) |
| 1564 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 1565 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1566 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1567 |
self.rm_testdir() |
| 1568 |
def test_59784_zzipdir_zap_CVE_2017_5978(self): |
| 1569 |
""" run unzzip -l $(CVE_2017_5978).zip """ |
| 1570 |
tmpdir = self.testdir() |
| 1571 |
filename = self.zip_CVE_2017_5978 |
| 1572 |
file_url = self.url_CVE_2017_5978 |
| 1573 |
if not download_raw(file_url, filename, tmpdir): |
| 1574 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1575 |
exe = self.bins("unzzip") |
| 1576 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1577 |
returncodes = [3]) |
| 1578 |
self.assertLess(len(run.output), 1) |
| 1579 |
self.assertLess(len(errors(run.errors)), 180) |
| 1580 |
# |
| 1581 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1582 |
returncodes = [0,3]) |
| 1583 |
self.assertLess(len(run.output), 30) |
| 1584 |
self.assertLess(len(errors(run.errors)), 300) |
| 1585 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 1586 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1587 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) |
| 1588 |
self.rm_testdir() |
| 1589 |
def test_59789(self): |
| 1590 |
""" check $(CVE).zip """ |
| 1591 |
tmpdir = self.testdir() |
| 1592 |
filename = self.zip_CVE_2017_5978 |
| 1593 |
file_url = self.url_CVE_2017_5978 |
| 1594 |
if not download_raw(file_url, filename, tmpdir): |
| 1595 |
self.skipTest("no zip_CVE_2017_5978 available: " + filename) |
| 1596 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 1597 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 1598 |
self.assertEqual(size, 161) |
| 1599 |
|
| 1600 |
url_CVE_2017_5979 = "https://github.com/asarubbo/poc/blob/master" |
| 1601 |
zip_CVE_2017_5979 = "00157-zziplib-nullptr-prescan_entry" |
| 1602 |
def test_59790_infozipdir_CVE_2017_5979(self): |
| 1603 |
""" run info-zip dir test0.zip """ |
| 1604 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1605 |
tmpdir = self.testdir() |
| 1606 |
filename = self.zip_CVE_2017_5979 |
| 1607 |
file_url = self.url_CVE_2017_5979 |
| 1608 |
if not download_raw(file_url, filename, tmpdir): |
| 1609 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1610 |
exe = self.bins("unzip") |
| 1611 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1612 |
returncodes = [0]) |
| 1613 |
self.assertIn(' 1 file', run.output) |
| 1614 |
self.assertLess(len(run.output), 330) |
| 1615 |
self.assertLess(len(errors(run.errors)), 1) |
| 1616 |
# |
| 1617 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1618 |
returncodes = [0]) |
| 1619 |
self.assertLess(len(run.output), 90) |
| 1620 |
self.assertLess(len(errors(run.errors)), 1) |
| 1621 |
self.assertIn('extracting: a', run.output) |
| 1622 |
self.assertEqual(os.path.getsize(tmpdir+"/a"), 3) |
| 1623 |
self.rm_testdir() |
| 1624 |
def test_59791_zzipdir_big_CVE_2017_5979(self): |
| 1625 |
""" run info-zip -l $(CVE_2017_5979).zip """ |
| 1626 |
tmpdir = self.testdir() |
| 1627 |
filename = self.zip_CVE_2017_5979 |
| 1628 |
file_url = self.url_CVE_2017_5979 |
| 1629 |
if not download_raw(file_url, filename, tmpdir): |
| 1630 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1631 |
exe = self.bins("unzzip-big") |
| 1632 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1633 |
returncodes = [0]) |
| 1634 |
self.assertLess(len(run.output), 30) |
| 1635 |
self.assertLess(len(errors(run.errors)), 1) |
| 1636 |
self.assertIn(" stored a", run.output) |
| 1637 |
# |
| 1638 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1639 |
returncodes = [0]) |
| 1640 |
self.assertLess(len(run.output), 30) |
| 1641 |
self.assertLess(len(errors(run.errors)), 1) |
| 1642 |
self.assertEqual(os.path.getsize(tmpdir+"/a"), 3) |
| 1643 |
self.rm_testdir() |
| 1644 |
def test_59792_zzipdir_mem_CVE_2017_5979(self): |
| 1645 |
""" run unzzip-mem -l $(CVE_2017_5979).zip """ |
| 1646 |
tmpdir = self.testdir() |
| 1647 |
filename = self.zip_CVE_2017_5979 |
| 1648 |
file_url = self.url_CVE_2017_5979 |
| 1649 |
if not download_raw(file_url, filename, tmpdir): |
| 1650 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1651 |
exe = self.bins("unzzip-mem") |
| 1652 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1653 |
returncodes = [0]) |
| 1654 |
self.assertLess(len(run.output), 30) |
| 1655 |
self.assertLess(len(errors(run.errors)), 1) |
| 1656 |
self.assertIn(" 3 a", run.output) |
| 1657 |
# |
| 1658 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1659 |
returncodes = [0]) |
| 1660 |
self.assertLess(len(run.output), 30) |
| 1661 |
self.assertEqual(os.path.getsize(tmpdir+"/a"), 3) |
| 1662 |
self.rm_testdir() |
| 1663 |
def test_59793_zzipdir_mix_CVE_2017_5979(self): |
| 1664 |
""" run unzzip-mix -l $(CVE_2017_5979).zip """ |
| 1665 |
tmpdir = self.testdir() |
| 1666 |
filename = self.zip_CVE_2017_5979 |
| 1667 |
file_url = self.url_CVE_2017_5979 |
| 1668 |
if not download_raw(file_url, filename, tmpdir): |
| 1669 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1670 |
exe = self.bins("unzzip-mix") |
| 1671 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1672 |
returncodes = [0]) |
| 1673 |
self.assertLess(len(run.output), 30) |
| 1674 |
self.assertLess(len(errors(run.errors)), 1) |
| 1675 |
self.assertIn(" 3 a", run.output) |
| 1676 |
# |
| 1677 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1678 |
returncodes = [0]) |
| 1679 |
self.assertLess(len(run.output), 30) |
| 1680 |
self.assertLess(len(errors(run.errors)), 20) |
| 1681 |
self.assertEqual(os.path.getsize(tmpdir+"/a"), 0) # FIXME |
| 1682 |
# self.assertEqual(os.path.getsize(tmpdir+"/a"), 3) # FIXME |
| 1683 |
self.rm_testdir() |
| 1684 |
def test_59794_zzipdir_zap_CVE_2017_5979(self): |
| 1685 |
""" run unzzip -l $(CVE_2017_5979).zip """ |
| 1686 |
tmpdir = self.testdir() |
| 1687 |
filename = self.zip_CVE_2017_5979 |
| 1688 |
file_url = self.url_CVE_2017_5979 |
| 1689 |
if not download_raw(file_url, filename, tmpdir): |
| 1690 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1691 |
exe = self.bins("unzzip") |
| 1692 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1693 |
returncodes = [0, 255]) |
| 1694 |
self.assertLess(len(run.output), 30) |
| 1695 |
self.assertLess(len(errors(run.errors)), 1) |
| 1696 |
self.assertIn(" 3 a", run.output) |
| 1697 |
# |
| 1698 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1699 |
returncodes = [0]) |
| 1700 |
self.assertLess(len(run.output), 30) |
| 1701 |
self.assertLess(len(errors(run.errors)), 20) |
| 1702 |
self.assertEqual(os.path.getsize(tmpdir+"/a"), 3) |
| 1703 |
self.rm_testdir() |
| 1704 |
def test_59799(self): |
| 1705 |
""" check $(CVE).zip """ |
| 1706 |
tmpdir = self.testdir() |
| 1707 |
filename = self.zip_CVE_2017_5979 |
| 1708 |
file_url = self.url_CVE_2017_5979 |
| 1709 |
if not download_raw(file_url, filename, tmpdir): |
| 1710 |
self.skipTest("no zip_CVE_2017_5979 available: " + filename) |
| 1711 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 1712 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 1713 |
self.assertEqual(size, 155) |
| 1714 |
|
| 1715 |
|
| 1716 |
url_CVE_2017_5974 = "https://github.com/asarubbo/poc/blob/master" |
| 1717 |
zip_CVE_2017_5974 = "00150-zziplib-heapoverflow-__zzip_get32" |
| 1718 |
def test_59740_infozipdir_CVE_2017_5974(self): |
| 1719 |
""" run info-zip dir test0.zip """ |
| 1720 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1721 |
tmpdir = self.testdir() |
| 1722 |
filename = self.zip_CVE_2017_5974 |
| 1723 |
file_url = self.url_CVE_2017_5974 |
| 1724 |
if not download_raw(file_url, filename, tmpdir): |
| 1725 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1726 |
exe = self.bins("unzip") |
| 1727 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1728 |
returncodes = [0, 9]) |
| 1729 |
self.assertIn(' 1 file', run.output) |
| 1730 |
self.assertLess(len(run.output), 330) |
| 1731 |
self.assertLess(len(errors(run.errors)), 1) |
| 1732 |
# |
| 1733 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1734 |
returncodes = [0]) |
| 1735 |
self.assertLess(len(run.output), 90) |
| 1736 |
self.assertLess(len(errors(run.errors)), 1) |
| 1737 |
self.assertIn(" extracting: test", run.output) |
| 1738 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1739 |
self.rm_testdir() |
| 1740 |
def test_59741_zzipdir_big_CVE_2017_5974(self): |
| 1741 |
""" run unzzip-big -l $(CVE_2017_5974).zip """ |
| 1742 |
tmpdir = self.testdir() |
| 1743 |
filename = self.zip_CVE_2017_5974 |
| 1744 |
file_url = self.url_CVE_2017_5974 |
| 1745 |
if not download_raw(file_url, filename, tmpdir): |
| 1746 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1747 |
exe = self.bins("unzzip-big") |
| 1748 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1749 |
returncodes = [0]) |
| 1750 |
self.assertLess(len(run.output), 30) |
| 1751 |
self.assertLess(len(errors(run.errors)), 1) |
| 1752 |
self.assertIn(" stored test", run.output) |
| 1753 |
# |
| 1754 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1755 |
returncodes = [0]) |
| 1756 |
self.assertLess(len(run.output), 30) |
| 1757 |
self.assertLess(len(errors(run.errors)), 1) |
| 1758 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1759 |
self.rm_testdir() |
| 1760 |
def test_59742_zzipdir_mem_CVE_2017_5974(self): |
| 1761 |
""" run unzzip-mem -l $(CVE_2017_5974).zip """ |
| 1762 |
tmpdir = self.testdir() |
| 1763 |
filename = self.zip_CVE_2017_5974 |
| 1764 |
file_url = self.url_CVE_2017_5974 |
| 1765 |
if not download_raw(file_url, filename, tmpdir): |
| 1766 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1767 |
exe = self.bins("unzzip-mem") |
| 1768 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1769 |
returncodes = [0]) |
| 1770 |
self.assertLess(len(run.output), 30) |
| 1771 |
self.assertLess(len(errors(run.errors)), 1) |
| 1772 |
self.assertIn(" 3 test", run.output) |
| 1773 |
# |
| 1774 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1775 |
returncodes = [0]) |
| 1776 |
self.assertLess(len(run.output), 30) |
| 1777 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1778 |
self.rm_testdir() |
| 1779 |
def test_59743_zzipdir_mix_CVE_2017_5974(self): |
| 1780 |
""" run unzzip-mix -l $(CVE_2017_5974).zip """ |
| 1781 |
tmpdir = self.testdir() |
| 1782 |
filename = self.zip_CVE_2017_5974 |
| 1783 |
file_url = self.url_CVE_2017_5974 |
| 1784 |
if not download_raw(file_url, filename, tmpdir): |
| 1785 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1786 |
exe = self.bins("unzzip-mix") |
| 1787 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1788 |
returncodes = [0]) |
| 1789 |
self.assertLess(len(run.output), 30) |
| 1790 |
self.assertLess(len(errors(run.errors)), 1) |
| 1791 |
self.assertIn(" 3 test", run.output) |
| 1792 |
# |
| 1793 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1794 |
returncodes = [0]) |
| 1795 |
self.assertLess(len(run.output), 30) |
| 1796 |
self.assertLess(len(errors(run.errors)), 1) |
| 1797 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) # FIXME |
| 1798 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) # FIXME |
| 1799 |
self.rm_testdir() |
| 1800 |
def test_59744_zzipdir_zap_CVE_2017_5974(self): |
| 1801 |
""" run unzzip -l $(CVE_2017_5974).zip """ |
| 1802 |
tmpdir = self.testdir() |
| 1803 |
filename = self.zip_CVE_2017_5974 |
| 1804 |
file_url = self.url_CVE_2017_5974 |
| 1805 |
if not download_raw(file_url, filename, tmpdir): |
| 1806 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1807 |
exe = self.bins("unzzip") |
| 1808 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1809 |
returncodes = [0, 255]) |
| 1810 |
self.assertLess(len(run.output), 30) |
| 1811 |
self.assertLess(len(errors(run.errors)), 1) |
| 1812 |
self.assertIn(" 3 test", run.output) |
| 1813 |
# |
| 1814 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1815 |
returncodes = [0]) |
| 1816 |
self.assertLess(len(run.output), 30) |
| 1817 |
self.assertLess(len(errors(run.errors)), 1) |
| 1818 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1819 |
self.rm_testdir() |
| 1820 |
def test_59749(self): |
| 1821 |
""" check $(CVE).zip """ |
| 1822 |
tmpdir = self.testdir() |
| 1823 |
filename = self.zip_CVE_2017_5974 |
| 1824 |
file_url = self.url_CVE_2017_5974 |
| 1825 |
if not download_raw(file_url, filename, tmpdir): |
| 1826 |
self.skipTest("no zip_CVE_2017_5974 available: " + filename) |
| 1827 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 1828 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 1829 |
self.assertEqual(size, 161) |
| 1830 |
|
| 1831 |
url_CVE_2017_5975 = "https://github.com/asarubbo/poc/blob/master" |
| 1832 |
zip_CVE_2017_5975 = "00151-zziplib-heapoverflow-__zzip_get64" |
| 1833 |
def test_59750_infozipdir_CVE_2017_5975(self): |
| 1834 |
""" run info-zip dir test0.zip """ |
| 1835 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1836 |
tmpdir = self.testdir() |
| 1837 |
filename = self.zip_CVE_2017_5975 |
| 1838 |
file_url = self.url_CVE_2017_5975 |
| 1839 |
if not download_raw(file_url, filename, tmpdir): |
| 1840 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1841 |
exe = self.bins("unzip") |
| 1842 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1843 |
returncodes = [0, 2]) |
| 1844 |
self.assertIn(' missing 10 bytes in zipfile', run.errors) |
| 1845 |
self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors) |
| 1846 |
self.assertIn(' 1 file', run.output) |
| 1847 |
self.assertLess(len(run.output), 330) |
| 1848 |
self.assertLess(len(errors(run.errors)), 430) |
| 1849 |
# |
| 1850 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1851 |
returncodes = [2]) |
| 1852 |
self.assertLess(len(run.output), 90) |
| 1853 |
self.assertLess(len(errors(run.errors)), 900) |
| 1854 |
self.assertIn('file #1: bad zipfile offset (local header sig): 127', run.errors) |
| 1855 |
#self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1856 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1857 |
self.rm_testdir() |
| 1858 |
def test_59751_zzipdir_big_CVE_2017_5975(self): |
| 1859 |
""" run info-zip -l $(CVE_2017_5975).zip """ |
| 1860 |
tmpdir = self.testdir() |
| 1861 |
filename = self.zip_CVE_2017_5975 |
| 1862 |
file_url = self.url_CVE_2017_5975 |
| 1863 |
if not download_raw(file_url, filename, tmpdir): |
| 1864 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1865 |
exe = self.bins("unzzip-big") |
| 1866 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1867 |
returncodes = [0]) |
| 1868 |
self.assertLess(len(run.output), 30) |
| 1869 |
self.assertLess(len(errors(run.errors)), 1) |
| 1870 |
self.assertIn(" stored test", run.output) |
| 1871 |
# |
| 1872 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1873 |
returncodes = [0]) |
| 1874 |
self.assertLess(len(run.output), 30) |
| 1875 |
self.assertLess(len(errors(run.errors)), 1) |
| 1876 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) # TODO |
| 1877 |
self.rm_testdir() |
| 1878 |
def test_59752_zzipdir_mem_CVE_2017_5975(self): |
| 1879 |
""" run unzzip-mem -l $(CVE_2017_5975).zip """ |
| 1880 |
tmpdir = self.testdir() |
| 1881 |
filename = self.zip_CVE_2017_5975 |
| 1882 |
file_url = self.url_CVE_2017_5975 |
| 1883 |
if not download_raw(file_url, filename, tmpdir): |
| 1884 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1885 |
exe = self.bins("unzzip-mem") |
| 1886 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1887 |
returncodes = [0]) |
| 1888 |
self.assertLess(len(run.output), 1) |
| 1889 |
self.assertLess(len(errors(run.errors)), 180) |
| 1890 |
self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors) |
| 1891 |
self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors) |
| 1892 |
# |
| 1893 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1894 |
returncodes = [0]) |
| 1895 |
self.assertLess(len(run.output), 30) |
| 1896 |
self.assertLess(len(errors(run.errors)), 200) |
| 1897 |
if grep("DEBUG:", run.errors): |
| 1898 |
self.assertIn("no header in entry", run.errors) |
| 1899 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1900 |
self.rm_testdir() |
| 1901 |
def test_59753_zzipdir_mix_CVE_2017_5975(self): |
| 1902 |
""" run unzzip-mix -l $(CVE_2017_5975).zip """ |
| 1903 |
tmpdir = self.testdir() |
| 1904 |
filename = self.zip_CVE_2017_5975 |
| 1905 |
file_url = self.url_CVE_2017_5975 |
| 1906 |
if not download_raw(file_url, filename, tmpdir): |
| 1907 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1908 |
exe = self.bins("unzzip-mix") |
| 1909 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1910 |
returncodes = [0,2]) |
| 1911 |
self.assertLess(len(run.output), 1) |
| 1912 |
self.assertLess(len(errors(run.errors)), 180) |
| 1913 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 1914 |
# |
| 1915 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1916 |
returncodes = [0,2]) |
| 1917 |
self.assertLess(len(run.output), 30) |
| 1918 |
self.assertLess(len(errors(run.errors)), 200) |
| 1919 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 1920 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1921 |
self.rm_testdir() |
| 1922 |
def test_59754_zzipdir_zap_CVE_2017_5975(self): |
| 1923 |
""" run unzzip -l $(CVE_2017_5975).zip """ |
| 1924 |
tmpdir = self.testdir() |
| 1925 |
filename = self.zip_CVE_2017_5975 |
| 1926 |
file_url = self.url_CVE_2017_5975 |
| 1927 |
if not download_raw(file_url, filename, tmpdir): |
| 1928 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1929 |
exe = self.bins("unzzip") |
| 1930 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1931 |
returncodes = [0,3]) |
| 1932 |
self.assertLess(len(run.output), 1) |
| 1933 |
self.assertLess(len(errors(run.errors)), 180) |
| 1934 |
self.assertErrorMessage(run.errors, 0) |
| 1935 |
# |
| 1936 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1937 |
returncodes = [0,3]) |
| 1938 |
self.assertLess(len(run.output), 30) |
| 1939 |
self.assertLess(len(errors(run.errors)), 200) |
| 1940 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 1941 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1942 |
self.rm_testdir() |
| 1943 |
def test_59759(self): |
| 1944 |
""" check $(CVE).zip """ |
| 1945 |
tmpdir = self.testdir() |
| 1946 |
filename = self.zip_CVE_2017_5975 |
| 1947 |
file_url = self.url_CVE_2017_5975 |
| 1948 |
if not download_raw(file_url, filename, tmpdir): |
| 1949 |
self.skipTest("no zip_CVE_2017_5975 available: " + filename) |
| 1950 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 1951 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 1952 |
self.assertEqual(size, 151) |
| 1953 |
|
| 1954 |
|
| 1955 |
url_CVE_2017_5976 = "https://github.com/asarubbo/poc/blob/master" |
| 1956 |
zip_CVE_2017_5976 = "00152-zziplib-heapoverflow-zzip_mem_entry_extra_block" |
| 1957 |
def test_59760_infozipdir_CVE_2017_5976(self): |
| 1958 |
""" run info-zip dir test0.zip """ |
| 1959 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 1960 |
tmpdir = self.testdir() |
| 1961 |
filename = self.zip_CVE_2017_5976 |
| 1962 |
file_url = self.url_CVE_2017_5976 |
| 1963 |
if not download_raw(file_url, filename, tmpdir): |
| 1964 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 1965 |
exe = self.bins("unzip") |
| 1966 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1967 |
returncodes = [0, 2]) |
| 1968 |
self.assertIn(' 27 extra bytes at beginning or within zipfile', run.errors) |
| 1969 |
self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors) |
| 1970 |
self.assertIn(' 1 file', run.output) |
| 1971 |
self.assertLess(len(run.output), 330) |
| 1972 |
self.assertLess(len(errors(run.errors)), 500) |
| 1973 |
# |
| 1974 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 1975 |
returncodes = [2]) |
| 1976 |
self.assertLess(len(run.output), 190) |
| 1977 |
self.assertLess(len(errors(run.errors)), 900) |
| 1978 |
self.assertIn("extracting: test", run.output) |
| 1979 |
self.assertIn('-27 bytes too long', run.errors) |
| 1980 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 1981 |
# self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 1982 |
self.rm_testdir() |
| 1983 |
def test_59761_zzipdir_big_CVE_2017_5976(self): |
| 1984 |
""" run info-zip -l $(CVE_2017_5976).zip """ |
| 1985 |
tmpdir = self.testdir() |
| 1986 |
filename = self.zip_CVE_2017_5976 |
| 1987 |
file_url = self.url_CVE_2017_5976 |
| 1988 |
if not download_raw(file_url, filename, tmpdir): |
| 1989 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 1990 |
exe = self.bins("unzzip-big") |
| 1991 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 1992 |
returncodes = [0]) |
| 1993 |
self.assertLess(len(run.output), 30) |
| 1994 |
self.assertLess(len(errors(run.errors)), 1) |
| 1995 |
self.assertIn(" stored test", run.output) |
| 1996 |
# |
| 1997 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 1998 |
returncodes = [0]) |
| 1999 |
self.assertLess(len(run.output), 30) |
| 2000 |
self.assertLess(len(errors(run.errors)), 1) |
| 2001 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2002 |
self.rm_testdir() |
| 2003 |
def test_59762_zzipdir_mem_CVE_2017_5976(self): |
| 2004 |
""" run unzzip-mem -l $(CVE_2017_5976).zip """ |
| 2005 |
tmpdir = self.testdir() |
| 2006 |
filename = self.zip_CVE_2017_5976 |
| 2007 |
file_url = self.url_CVE_2017_5976 |
| 2008 |
if not download_raw(file_url, filename, tmpdir): |
| 2009 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 2010 |
exe = self.bins("unzzip-mem") |
| 2011 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2012 |
returncodes = [0]) |
| 2013 |
self.assertLess(len(run.output), 30) |
| 2014 |
self.assertLess(len(errors(run.errors)), 1) |
| 2015 |
self.assertIn("3 test", run.output) |
| 2016 |
# |
| 2017 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2018 |
returncodes = [0]) |
| 2019 |
self.assertLess(len(run.output), 30) |
| 2020 |
self.assertLess(len(errors(run.errors)), 30) # TODO |
| 2021 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2022 |
self.rm_testdir() |
| 2023 |
def test_59763_zzipdir_mix_CVE_2017_5976(self): |
| 2024 |
""" run unzzip-mix -l $(CVE_2017_5976).zip """ |
| 2025 |
tmpdir = self.testdir() |
| 2026 |
filename = self.zip_CVE_2017_5976 |
| 2027 |
file_url = self.url_CVE_2017_5976 |
| 2028 |
if not download_raw(file_url, filename, tmpdir): |
| 2029 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 2030 |
exe = self.bins("unzzip-mix") |
| 2031 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2032 |
returncodes = [0]) |
| 2033 |
self.assertLess(len(run.output), 30) |
| 2034 |
self.assertLess(len(errors(run.errors)), 1) |
| 2035 |
self.assertIn("3 test", run.output) |
| 2036 |
# |
| 2037 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2038 |
returncodes = [0]) |
| 2039 |
self.assertLess(len(run.output), 30) |
| 2040 |
self.assertLess(len(errors(run.errors)), 30) |
| 2041 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 0) # FIXME |
| 2042 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) # FIXME |
| 2043 |
self.rm_testdir() |
| 2044 |
def test_59764_zzipdir_zap_CVE_2017_5976(self): |
| 2045 |
""" run unzzip -l $(CVE_2017_5976).zip """ |
| 2046 |
tmpdir = self.testdir() |
| 2047 |
filename = self.zip_CVE_2017_5976 |
| 2048 |
file_url = self.url_CVE_2017_5976 |
| 2049 |
if not download_raw(file_url, filename, tmpdir): |
| 2050 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 2051 |
exe = self.bins("unzzip") |
| 2052 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2053 |
returncodes = [0, 255]) |
| 2054 |
self.assertLess(len(run.output), 30) |
| 2055 |
self.assertLess(len(errors(run.errors)), 1) |
| 2056 |
self.assertIn("3 test", run.output) |
| 2057 |
# |
| 2058 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2059 |
returncodes = [0]) |
| 2060 |
self.assertLess(len(run.output), 30) |
| 2061 |
self.assertLess(len(errors(run.errors)), 30) |
| 2062 |
self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2063 |
self.rm_testdir() |
| 2064 |
def test_59769(self): |
| 2065 |
""" check $(CVE).zip """ |
| 2066 |
tmpdir = self.testdir() |
| 2067 |
filename = self.zip_CVE_2017_5976 |
| 2068 |
file_url = self.url_CVE_2017_5976 |
| 2069 |
if not download_raw(file_url, filename, tmpdir): |
| 2070 |
self.skipTest("no zip_CVE_2017_5976 available: " + filename) |
| 2071 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2072 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2073 |
self.assertEqual(size, 188) |
| 2074 |
|
| 2075 |
url_CVE_2017_5980 = "https://github.com/asarubbo/poc/blob/master" |
| 2076 |
zip_CVE_2017_5980 = "00154-zziplib-nullptr-zzip_mem_entry_new" |
| 2077 |
def test_59800_infozipdir_CVE_2017_5980(self): |
| 2078 |
""" run info-zip dir test0.zip """ |
| 2079 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2080 |
tmpdir = self.testdir() |
| 2081 |
filename = self.zip_CVE_2017_5980 |
| 2082 |
file_url = self.url_CVE_2017_5980 |
| 2083 |
if not download_raw(file_url, filename, tmpdir): |
| 2084 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2085 |
exe = self.bins("unzip") |
| 2086 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2087 |
returncodes = [0, 2]) |
| 2088 |
self.assertIn(' missing 6 bytes in zipfile', run.errors) |
| 2089 |
self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors) |
| 2090 |
self.assertIn(' 1 file', run.output) |
| 2091 |
self.assertLess(len(run.output), 330) |
| 2092 |
self.assertLess(len(errors(run.errors)), 500) |
| 2093 |
# |
| 2094 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2095 |
returncodes = [3]) |
| 2096 |
self.assertLess(len(run.output), 90) |
| 2097 |
self.assertLess(len(errors(run.errors)), 900) |
| 2098 |
self.assertIn('file #1: bad zipfile offset (lseek)', run.errors) |
| 2099 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2100 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2101 |
self.rm_testdir() |
| 2102 |
def test_59801_zzipdir_big_CVE_2017_5980(self): |
| 2103 |
""" run info-zip -l $(CVE_2017_5980).zip """ |
| 2104 |
tmpdir = self.testdir() |
| 2105 |
filename = self.zip_CVE_2017_5980 |
| 2106 |
file_url = self.url_CVE_2017_5980 |
| 2107 |
if not download_raw(file_url, filename, tmpdir): |
| 2108 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2109 |
exe = self.bins("unzzip-big") |
| 2110 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2111 |
returncodes = [0]) |
| 2112 |
self.assertLess(len(run.output), 30) |
| 2113 |
self.assertLess(len(errors(run.errors)), 1) |
| 2114 |
self.assertIn(" stored (null)", run.output) |
| 2115 |
# |
| 2116 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2117 |
returncodes = [0,1]) |
| 2118 |
self.assertLess(len(run.output), 30) |
| 2119 |
self.assertLess(len(errors(run.errors)), 1) |
| 2120 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2121 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2122 |
self.rm_testdir() |
| 2123 |
def test_59802_zzipdir_mem_CVE_2017_5980(self): |
| 2124 |
""" run unzzip-mem -l $(CVE_2017_5980).zip """ |
| 2125 |
tmpdir = self.testdir() |
| 2126 |
filename = self.zip_CVE_2017_5980 |
| 2127 |
file_url = self.url_CVE_2017_5980 |
| 2128 |
if not download_raw(file_url, filename, tmpdir): |
| 2129 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2130 |
exe = self.bins("unzzip-mem") |
| 2131 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2132 |
returncodes = [0]) |
| 2133 |
self.assertLess(len(run.output), 1) |
| 2134 |
self.assertLess(len(errors(run.errors)), 180) |
| 2135 |
self.assertTrue(greps(run.errors, "unable to load disk")) |
| 2136 |
# |
| 2137 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2138 |
returncodes = [0]) |
| 2139 |
self.assertLess(len(run.output), 30) |
| 2140 |
self.assertLess(len(errors(run.errors)), 200) |
| 2141 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2142 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2143 |
self.rm_testdir() |
| 2144 |
def test_59803_zzipdir_mix_CVE_2017_5980(self): |
| 2145 |
""" run unzzip-mix -l $(CVE_2017_5980).zip """ |
| 2146 |
tmpdir = self.testdir() |
| 2147 |
filename = self.zip_CVE_2017_5980 |
| 2148 |
file_url = self.url_CVE_2017_5980 |
| 2149 |
if not download_raw(file_url, filename, tmpdir): |
| 2150 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2151 |
exe = self.bins("unzzip-mix") |
| 2152 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2153 |
returncodes = [2]) |
| 2154 |
self.assertLess(len(run.output), 1) |
| 2155 |
self.assertLess(len(errors(run.errors)), 180) |
| 2156 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2157 |
# |
| 2158 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2159 |
returncodes = [2]) |
| 2160 |
self.assertLess(len(run.output), 30) |
| 2161 |
self.assertLess(len(errors(run.errors)), 200) |
| 2162 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2163 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2164 |
self.rm_testdir() |
| 2165 |
def test_59804_zzipdir_zap_CVE_2017_5980(self): |
| 2166 |
""" run unzzip -l $(CVE_2017_5980).zip """ |
| 2167 |
tmpdir = self.testdir() |
| 2168 |
filename = self.zip_CVE_2017_5980 |
| 2169 |
file_url = self.url_CVE_2017_5980 |
| 2170 |
if not download_raw(file_url, filename, tmpdir): |
| 2171 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2172 |
exe = self.bins("unzzip") |
| 2173 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2174 |
returncodes = [3]) |
| 2175 |
self.assertLess(len(run.output), 1) |
| 2176 |
self.assertLess(len(errors(run.errors)), 180) |
| 2177 |
self.assertErrorMessage(run.errors, 0) |
| 2178 |
# |
| 2179 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2180 |
returncodes = [3]) # TODO |
| 2181 |
self.assertLess(len(run.output), 30) |
| 2182 |
self.assertLess(len(errors(run.errors)), 200) |
| 2183 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2184 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2185 |
self.rm_testdir() |
| 2186 |
def test_59809(self): |
| 2187 |
""" check $(CVE).zip """ |
| 2188 |
tmpdir = self.testdir() |
| 2189 |
filename = self.zip_CVE_2017_5980 |
| 2190 |
file_url = self.url_CVE_2017_5980 |
| 2191 |
if not download_raw(file_url, filename, tmpdir): |
| 2192 |
self.skipTest("no zip_CVE_2017_5980 available: " + filename) |
| 2193 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2194 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2195 |
self.assertEqual(size, 155) |
| 2196 |
|
| 2197 |
|
| 2198 |
url_CVE_2017_5981 = "https://github.com/asarubbo/poc/blob/master" |
| 2199 |
zip_CVE_2017_5981 = "00161-zziplib-assertionfailure-seeko_C" |
| 2200 |
def test_59810_infozipdir_CVE_2017_5981(self): |
| 2201 |
""" run info-zip dir test0.zip """ |
| 2202 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2203 |
tmpdir = self.testdir() |
| 2204 |
filename = self.zip_CVE_2017_5981 |
| 2205 |
file_url = self.url_CVE_2017_5981 |
| 2206 |
if not download_raw(file_url, filename, tmpdir): |
| 2207 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2208 |
exe = self.bins("unzip") |
| 2209 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2210 |
returncodes = [0, 3]) |
| 2211 |
self.assertIn(' missing 4 bytes in zipfile', run.errors) |
| 2212 |
self.assertIn("zipfile corrupt", run.errors) |
| 2213 |
self.assertLess(len(run.output), 80) |
| 2214 |
self.assertLess(len(errors(run.errors)), 500) |
| 2215 |
# |
| 2216 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2217 |
returncodes = [3]) |
| 2218 |
self.assertLess(len(run.output), 90) |
| 2219 |
self.assertLess(len(errors(run.errors)), 500) |
| 2220 |
self.assertIn('zipfile corrupt.', run.errors) |
| 2221 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2222 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2223 |
self.rm_testdir() |
| 2224 |
def test_59811_zzipdir_big_CVE_2017_5981(self): |
| 2225 |
""" run info-zip -l $(CVE_2017_5981).zip """ |
| 2226 |
tmpdir = self.testdir() |
| 2227 |
filename = self.zip_CVE_2017_5981 |
| 2228 |
file_url = self.url_CVE_2017_5981 |
| 2229 |
if not download_raw(file_url, filename, tmpdir): |
| 2230 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2231 |
exe = self.bins("unzzip-big") |
| 2232 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2233 |
returncodes = [0]) |
| 2234 |
self.assertLess(len(run.output), 1) |
| 2235 |
self.assertLess(len(errors(run.errors)), 1) |
| 2236 |
# |
| 2237 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2238 |
returncodes = [0]) |
| 2239 |
self.assertLess(len(run.output), 30) |
| 2240 |
self.assertLess(len(errors(run.errors)), 1) |
| 2241 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2242 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2243 |
self.rm_testdir() |
| 2244 |
def test_59812_zzipdir_mem_CVE_2017_5981(self): |
| 2245 |
""" run unzzip-mem -l $(CVE_2017_5981).zip """ |
| 2246 |
tmpdir = self.testdir() |
| 2247 |
filename = self.zip_CVE_2017_5981 |
| 2248 |
file_url = self.url_CVE_2017_5981 |
| 2249 |
if not download_raw(file_url, filename, tmpdir): |
| 2250 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2251 |
exe = self.bins("unzzip-mem") |
| 2252 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2253 |
returncodes = [0]) |
| 2254 |
self.assertLess(len(run.output), 1) |
| 2255 |
self.assertLess(len(errors(run.errors)), 1) |
| 2256 |
# |
| 2257 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2258 |
returncodes = [0]) |
| 2259 |
self.assertLess(len(run.output), 30) |
| 2260 |
self.assertLess(len(errors(run.errors)), 10) |
| 2261 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2262 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2263 |
self.rm_testdir() |
| 2264 |
def test_59813_zzipdir_mix_CVE_2017_5981(self): |
| 2265 |
""" run unzzip-mix -l $(CVE_2017_5981).zip """ |
| 2266 |
tmpdir = self.testdir() |
| 2267 |
filename = self.zip_CVE_2017_5981 |
| 2268 |
file_url = self.url_CVE_2017_5981 |
| 2269 |
if not download_raw(file_url, filename, tmpdir): |
| 2270 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2271 |
exe = self.bins("unzzip-mix") |
| 2272 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2273 |
returncodes = [0,2]) |
| 2274 |
self.assertLess(len(run.output), 1) |
| 2275 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2276 |
# |
| 2277 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2278 |
returncodes = [0,2]) |
| 2279 |
self.assertLess(len(run.output), 30) |
| 2280 |
self.assertLess(len(errors(run.errors)), 10) |
| 2281 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2282 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2283 |
self.rm_testdir() |
| 2284 |
def test_59814_zzipdir_zap_CVE_2017_5981(self): |
| 2285 |
""" run unzzip-zap -l $(CVE_2017_5981).zip """ |
| 2286 |
tmpdir = self.testdir() |
| 2287 |
filename = self.zip_CVE_2017_5981 |
| 2288 |
file_url = self.url_CVE_2017_5981 |
| 2289 |
if not download_raw(file_url, filename, tmpdir): |
| 2290 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2291 |
exe = self.bins("unzzip") |
| 2292 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2293 |
returncodes = [0,3]) |
| 2294 |
self.assertLess(len(run.output), 1) |
| 2295 |
self.assertLess(len(errors(run.errors)), 80) |
| 2296 |
self.assertErrorMessage(run.errors, 0) |
| 2297 |
# |
| 2298 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2299 |
returncodes = [0,3]) |
| 2300 |
self.assertLess(len(run.output), 30) |
| 2301 |
self.assertLess(len(errors(run.errors)), 10) |
| 2302 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2303 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2304 |
self.rm_testdir() |
| 2305 |
def test_59819(self): |
| 2306 |
""" check $(CVE).zip """ |
| 2307 |
tmpdir = self.testdir() |
| 2308 |
filename = self.zip_CVE_2017_5981 |
| 2309 |
file_url = self.url_CVE_2017_5981 |
| 2310 |
if not download_raw(file_url, filename, tmpdir): |
| 2311 |
self.skipTest("no zip_CVE_2017_5981 available: " + filename) |
| 2312 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2313 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2314 |
self.assertEqual(size, 157) |
| 2315 |
|
| 2316 |
url_CVE_2018_10 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2317 |
zip_CVE_2018_10 = "zziplib_0-13-67_zzdir_invalid-memory-access_main.zip" |
| 2318 |
def test_63010(self): |
| 2319 |
""" info unzip -l $(CVE).zip """ |
| 2320 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2321 |
tmpdir = self.testdir() |
| 2322 |
filename = self.zip_CVE_2018_10 |
| 2323 |
file_url = self.url_CVE_2018_10 |
| 2324 |
if not download_raw(file_url, filename, tmpdir): |
| 2325 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2326 |
exe = self.bins("unzip") |
| 2327 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2328 |
returncodes = [0, 9]) |
| 2329 |
self.assertIn("End-of-central-directory signature not found", run.errors) |
| 2330 |
self.assertLess(len(run.output), 80) |
| 2331 |
self.assertLess(len(errors(run.errors)), 600) |
| 2332 |
# |
| 2333 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2334 |
returncodes = [9]) |
| 2335 |
self.assertLess(len(run.output), 90) |
| 2336 |
self.assertLess(len(errors(run.errors)), 600) |
| 2337 |
self.assertIn('End-of-central-directory signature not found', run.errors) |
| 2338 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2339 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2340 |
self.rm_testdir() |
| 2341 |
def test_63011(self): |
| 2342 |
""" unzzip-big -l $(CVE).zip """ |
| 2343 |
tmpdir = self.testdir() |
| 2344 |
filename = self.zip_CVE_2018_10 |
| 2345 |
file_url = self.url_CVE_2018_10 |
| 2346 |
if not download_raw(file_url, filename, tmpdir): |
| 2347 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2348 |
exe = self.bins("unzzip-big") |
| 2349 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2350 |
returncodes = [0]) |
| 2351 |
self.assertLess(len(run.output), 1) |
| 2352 |
self.assertLess(len(errors(run.errors)), 1) |
| 2353 |
# |
| 2354 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2355 |
returncodes = [0]) |
| 2356 |
self.assertLess(len(run.output), 30) |
| 2357 |
self.assertLess(len(errors(run.errors)), 1) |
| 2358 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2359 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2360 |
self.rm_testdir() |
| 2361 |
def test_63012(self): |
| 2362 |
""" unzzip-mem -l $(CVE).zip """ |
| 2363 |
tmpdir = self.testdir() |
| 2364 |
filename = self.zip_CVE_2018_10 |
| 2365 |
file_url = self.url_CVE_2018_10 |
| 2366 |
if not download_raw(file_url, filename, tmpdir): |
| 2367 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2368 |
exe = self.bins("unzzip-mem") |
| 2369 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2370 |
returncodes = [0]) |
| 2371 |
self.assertLess(len(run.output), 1) |
| 2372 |
self.assertLess(len(errors(run.errors)), 1) |
| 2373 |
# |
| 2374 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2375 |
returncodes = [0]) |
| 2376 |
self.assertLess(len(run.output), 30) |
| 2377 |
self.assertLess(len(errors(run.errors)), 10) |
| 2378 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2379 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2380 |
self.rm_testdir() |
| 2381 |
def test_63013(self): |
| 2382 |
""" unzzip-mix -l $(CVE).zip """ |
| 2383 |
tmpdir = self.testdir() |
| 2384 |
filename = self.zip_CVE_2018_10 |
| 2385 |
file_url = self.url_CVE_2018_10 |
| 2386 |
if not download_raw(file_url, filename, tmpdir): |
| 2387 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2388 |
exe = self.bins("unzzip-mix") |
| 2389 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2390 |
returncodes = [0,2]) |
| 2391 |
self.assertLess(len(run.output), 1) |
| 2392 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2393 |
# |
| 2394 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2395 |
returncodes = [0,2]) |
| 2396 |
self.assertLess(len(run.output), 30) |
| 2397 |
self.assertLess(len(errors(run.errors)), 10) |
| 2398 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2399 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2400 |
self.rm_testdir() |
| 2401 |
def test_63014(self): |
| 2402 |
""" unzzip-zap -l $(CVE).zip """ |
| 2403 |
tmpdir = self.testdir() |
| 2404 |
filename = self.zip_CVE_2018_10 |
| 2405 |
file_url = self.url_CVE_2018_10 |
| 2406 |
if not download_raw(file_url, filename, tmpdir): |
| 2407 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2408 |
exe = self.bins("unzzip") |
| 2409 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2410 |
returncodes = [0,3]) |
| 2411 |
self.assertLess(len(run.output), 1) |
| 2412 |
self.assertLess(len(errors(run.errors)), 80) |
| 2413 |
self.assertErrorMessage(run.errors, 0) |
| 2414 |
# |
| 2415 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2416 |
returncodes = [0,3]) |
| 2417 |
self.assertLess(len(run.output), 30) |
| 2418 |
self.assertLess(len(errors(run.errors)), 10) |
| 2419 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2420 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2421 |
self.rm_testdir() |
| 2422 |
def test_63018(self): |
| 2423 |
""" zzdir on $(CVE).zip """ |
| 2424 |
tmpdir = self.testdir() |
| 2425 |
filename = self.zip_CVE_2018_10 |
| 2426 |
file_url = self.url_CVE_2018_10 |
| 2427 |
if not download_raw(file_url, filename, tmpdir): |
| 2428 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2429 |
exe = self.bins("zzdir") |
| 2430 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2431 |
returncodes = [1]) |
| 2432 |
self.assertLess(len(run.output), 1) |
| 2433 |
self.assertLess(len(errors(run.errors)), 80) |
| 2434 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2435 |
def test_63019(self): |
| 2436 |
""" check $(CVE).zip """ |
| 2437 |
tmpdir = self.testdir() |
| 2438 |
filename = self.zip_CVE_2018_10 |
| 2439 |
file_url = self.url_CVE_2018_10 |
| 2440 |
if not download_raw(file_url, filename, tmpdir): |
| 2441 |
self.skipTest("no zip_CVE_2018_10 available: " + filename) |
| 2442 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2443 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2444 |
self.assertEqual(size, 188) |
| 2445 |
|
| 2446 |
url_CVE_2018_11 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2447 |
zip_CVE_2018_11 = "zziplib_0-13-67_unzzip_infinite-loop_unzzip_cat_file.zip" |
| 2448 |
def test_63110(self): |
| 2449 |
""" info unzip -l $(CVE).zip """ |
| 2450 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2451 |
tmpdir = self.testdir() |
| 2452 |
filename = self.zip_CVE_2018_11 |
| 2453 |
file_url = self.url_CVE_2018_11 |
| 2454 |
if not download_raw(file_url, filename, tmpdir): |
| 2455 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2456 |
exe = self.bins("unzip") |
| 2457 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2458 |
returncodes = [0, 9]) |
| 2459 |
self.assertIn("End-of-central-directory signature not found", run.errors) |
| 2460 |
self.assertLess(len(run.output), 90) |
| 2461 |
self.assertLess(len(errors(run.errors)), 600) |
| 2462 |
# |
| 2463 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2464 |
returncodes = [9]) |
| 2465 |
self.assertLess(len(run.output), 90) |
| 2466 |
self.assertLess(len(errors(run.errors)), 600) |
| 2467 |
self.assertIn('End-of-central-directory signature not found', run.errors) |
| 2468 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2469 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2470 |
self.rm_testdir() |
| 2471 |
def test_63111(self): |
| 2472 |
""" unzzip-big -l $(CVE).zip """ |
| 2473 |
tmpdir = self.testdir() |
| 2474 |
filename = self.zip_CVE_2018_11 |
| 2475 |
file_url = self.url_CVE_2018_11 |
| 2476 |
if not download_raw(file_url, filename, tmpdir): |
| 2477 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2478 |
exe = self.bins("unzzip-big") |
| 2479 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2480 |
returncodes = [0]) |
| 2481 |
self.assertLess(len(run.output), 1) |
| 2482 |
self.assertLess(len(errors(run.errors)), 1) |
| 2483 |
# |
| 2484 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2485 |
returncodes = [0]) |
| 2486 |
self.assertLess(len(run.output), 30) |
| 2487 |
self.assertLess(len(errors(run.errors)), 1) |
| 2488 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2489 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2490 |
self.rm_testdir() |
| 2491 |
def test_63112(self): |
| 2492 |
""" unzzip-mem -l $(CVE).zip """ |
| 2493 |
tmpdir = self.testdir() |
| 2494 |
filename = self.zip_CVE_2018_11 |
| 2495 |
file_url = self.url_CVE_2018_11 |
| 2496 |
if not download_raw(file_url, filename, tmpdir): |
| 2497 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2498 |
exe = self.bins("unzzip-mem") |
| 2499 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2500 |
returncodes = [0]) |
| 2501 |
self.assertLess(len(run.output), 1) |
| 2502 |
self.assertLess(len(errors(run.errors)), 1) |
| 2503 |
# |
| 2504 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2505 |
returncodes = [0]) |
| 2506 |
self.assertLess(len(run.output), 30) |
| 2507 |
self.assertLess(len(errors(run.errors)), 10) |
| 2508 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2509 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2510 |
self.rm_testdir() |
| 2511 |
def test_63113(self): |
| 2512 |
""" unzzip-mix -l $(CVE).zip """ |
| 2513 |
tmpdir = self.testdir() |
| 2514 |
filename = self.zip_CVE_2018_11 |
| 2515 |
file_url = self.url_CVE_2018_11 |
| 2516 |
if not download_raw(file_url, filename, tmpdir): |
| 2517 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2518 |
exe = self.bins("unzzip-mix") |
| 2519 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2520 |
returncodes = [0,2]) |
| 2521 |
self.assertLess(len(run.output), 1) |
| 2522 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2523 |
# |
| 2524 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2525 |
returncodes = [0,2]) |
| 2526 |
self.assertLess(len(run.output), 30) |
| 2527 |
self.assertLess(len(errors(run.errors)), 10) |
| 2528 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2529 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2530 |
self.rm_testdir() |
| 2531 |
def test_63114(self): |
| 2532 |
""" unzzip-zap -l $(CVE).zip """ |
| 2533 |
tmpdir = self.testdir() |
| 2534 |
filename = self.zip_CVE_2018_11 |
| 2535 |
file_url = self.url_CVE_2018_11 |
| 2536 |
if not download_raw(file_url, filename, tmpdir): |
| 2537 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2538 |
exe = self.bins("unzzip") |
| 2539 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2540 |
returncodes = [0,3]) |
| 2541 |
self.assertLess(len(run.output), 1) |
| 2542 |
self.assertLess(len(errors(run.errors)), 90) |
| 2543 |
self.assertErrorMessage(run.errors, 0) |
| 2544 |
# |
| 2545 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2546 |
returncodes = [0,3]) |
| 2547 |
self.assertLess(len(run.output), 30) |
| 2548 |
self.assertLess(len(errors(run.errors)), 10) |
| 2549 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2550 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2551 |
# |
| 2552 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 2553 |
returncodes = [0,3]) |
| 2554 |
self.rm_testdir() |
| 2555 |
def test_63119(self): |
| 2556 |
""" check $(CVE).zip """ |
| 2557 |
tmpdir = self.testdir() |
| 2558 |
filename = self.zip_CVE_2018_11 |
| 2559 |
file_url = self.url_CVE_2018_11 |
| 2560 |
if not download_raw(file_url, filename, tmpdir): |
| 2561 |
self.skipTest("no zip_CVE_2018_11 available: " + filename) |
| 2562 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2563 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2564 |
self.assertEqual(size, 280) |
| 2565 |
|
| 2566 |
url_CVE_2018_12 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2567 |
zip_CVE_2018_12 = "zziplib_0-13-67_unzip-mem_buffer-access-with-incorrect-length-value_zzip_disk_fread.zip" |
| 2568 |
def test_63810(self): |
| 2569 |
""" info unzip -l $(CVE).zip """ |
| 2570 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2571 |
tmpdir = self.testdir() |
| 2572 |
filename = self.zip_CVE_2018_12 |
| 2573 |
file_url = self.url_CVE_2018_12 |
| 2574 |
if not download_raw(file_url, filename, tmpdir): |
| 2575 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2576 |
exe = self.bins("unzip") |
| 2577 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2578 |
returncodes = [2]) |
| 2579 |
self.assertIn('reported length of central directory', run.errors) |
| 2580 |
self.assertLess(len(run.output), 300) |
| 2581 |
self.assertLess(len(errors(run.errors)), 800) |
| 2582 |
# |
| 2583 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2584 |
returncodes = [2]) |
| 2585 |
self.assertLess(len(run.output), 300) |
| 2586 |
self.assertLess(len(errors(run.errors)), 800) |
| 2587 |
self.assertIn('reported length of central directory', run.errors) |
| 2588 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2589 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2590 |
self.rm_testdir() |
| 2591 |
def test_63811(self): |
| 2592 |
""" unzzip-big -l $(CVE).zip """ |
| 2593 |
tmpdir = self.testdir() |
| 2594 |
filename = self.zip_CVE_2018_12 |
| 2595 |
file_url = self.url_CVE_2018_12 |
| 2596 |
if not download_raw(file_url, filename, tmpdir): |
| 2597 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2598 |
exe = self.bins("unzzip-big") |
| 2599 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2600 |
returncodes = [0]) |
| 2601 |
self.assertLess(len(run.output), 20) |
| 2602 |
self.assertLess(len(errors(run.errors)), 1) |
| 2603 |
# |
| 2604 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2605 |
returncodes = [0]) |
| 2606 |
self.assertLess(len(run.output), 30) |
| 2607 |
self.assertLess(len(errors(run.errors)), 1) |
| 2608 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2609 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2610 |
self.rm_testdir() |
| 2611 |
def test_63812(self): |
| 2612 |
""" unzzip-mem -l $(CVE).zip """ |
| 2613 |
tmpdir = self.testdir() |
| 2614 |
filename = self.zip_CVE_2018_12 |
| 2615 |
file_url = self.url_CVE_2018_12 |
| 2616 |
if not download_raw(file_url, filename, tmpdir): |
| 2617 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2618 |
exe = self.bins("unzzip-mem") |
| 2619 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2620 |
returncodes = [0]) |
| 2621 |
self.assertIn("2 aUT", run.output) # filename contains a control-character |
| 2622 |
self.assertGreater(len(run.output), 20) |
| 2623 |
self.assertLess(len(errors(run.errors)), 1) |
| 2624 |
# |
| 2625 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2626 |
returncodes = [0]) |
| 2627 |
self.assertLess(len(run.output), 30) |
| 2628 |
self.assertLess(len(errors(run.errors)), 10) |
| 2629 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2630 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2631 |
self.rm_testdir() |
| 2632 |
def test_63813(self): |
| 2633 |
""" unzzip-mix -l $(CVE).zip """ |
| 2634 |
tmpdir = self.testdir() |
| 2635 |
filename = self.zip_CVE_2018_12 |
| 2636 |
file_url = self.url_CVE_2018_12 |
| 2637 |
if not download_raw(file_url, filename, tmpdir): |
| 2638 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2639 |
exe = self.bins("unzzip-mix") |
| 2640 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2641 |
returncodes = [0,2]) |
| 2642 |
self.assertLess(len(run.output), 1) |
| 2643 |
self.assertTrue(grep(run.errors, "central directory not found")) |
| 2644 |
# |
| 2645 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2646 |
returncodes = [0,2]) |
| 2647 |
self.assertLess(len(run.output), 30) |
| 2648 |
self.assertLess(len(errors(run.errors)), 10) |
| 2649 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2650 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2651 |
self.rm_testdir() |
| 2652 |
def test_63814(self): |
| 2653 |
""" unzzip-zap -l $(CVE).zip """ |
| 2654 |
tmpdir = self.testdir() |
| 2655 |
filename = self.zip_CVE_2018_12 |
| 2656 |
file_url = self.url_CVE_2018_12 |
| 2657 |
if not download_raw(file_url, filename, tmpdir): |
| 2658 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2659 |
exe = self.bins("unzzip") |
| 2660 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2661 |
returncodes = [0,3]) |
| 2662 |
self.assertLess(len(run.output), 1) |
| 2663 |
self.assertLess(len(errors(run.errors)), 200) |
| 2664 |
self.assertErrorMessage(run.errors, 0) |
| 2665 |
# |
| 2666 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2667 |
returncodes = [0,3]) |
| 2668 |
self.assertLess(len(run.output), 30) |
| 2669 |
self.assertLess(len(errors(run.errors)), 10) |
| 2670 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2671 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2672 |
self.rm_testdir() |
| 2673 |
def test_63819(self): |
| 2674 |
""" check $(CVE).zip """ |
| 2675 |
tmpdir = self.testdir() |
| 2676 |
filename = self.zip_CVE_2018_12 |
| 2677 |
file_url = self.url_CVE_2018_12 |
| 2678 |
if not download_raw(file_url, filename, tmpdir): |
| 2679 |
self.skipTest("no zip_CVE_2018_12 available: " + filename) |
| 2680 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2681 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2682 |
self.assertEqual(size, 141) |
| 2683 |
|
| 2684 |
url_CVE_2018_14 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2685 |
zip_CVE_2018_14 = "zziplib_0-13-67_zzdir_memory-alignment-errors___zzip_fetch_disk_trailer.zip" |
| 2686 |
def test_64840(self): |
| 2687 |
""" info unzip -l $(CVE).zip """ |
| 2688 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2689 |
tmpdir = self.testdir() |
| 2690 |
filename = self.zip_CVE_2018_14 |
| 2691 |
file_url = self.url_CVE_2018_14 |
| 2692 |
if not download_raw(file_url, filename, tmpdir): |
| 2693 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2694 |
exe = self.bins("unzip") |
| 2695 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2696 |
returncodes = [3]) |
| 2697 |
self.assertIn("attempt to seek before beginning of zipfile", run.errors) |
| 2698 |
self.assertLess(len(run.output), 200) |
| 2699 |
self.assertLess(len(errors(run.errors)), 800) |
| 2700 |
# |
| 2701 |
exe = self.bins("unzip") |
| 2702 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2703 |
returncodes = [3]) |
| 2704 |
self.assertLess(len(run.output), 200) |
| 2705 |
self.assertLess(len(errors(run.errors)), 800) |
| 2706 |
self.assertIn('attempt to seek before beginning of zipfile', run.errors) |
| 2707 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2708 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2709 |
self.rm_testdir() |
| 2710 |
def test_64841(self): |
| 2711 |
""" unzzip-big -l $(CVE).zip """ |
| 2712 |
tmpdir = self.testdir() |
| 2713 |
filename = self.zip_CVE_2018_14 |
| 2714 |
file_url = self.url_CVE_2018_14 |
| 2715 |
if not download_raw(file_url, filename, tmpdir): |
| 2716 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2717 |
exe = self.bins("unzzip-big") |
| 2718 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2719 |
returncodes = [0]) |
| 2720 |
self.assertLess(len(run.output), 1) |
| 2721 |
self.assertLess(len(errors(run.errors)), 1) |
| 2722 |
# |
| 2723 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2724 |
returncodes = [0]) |
| 2725 |
self.assertLess(len(run.output), 30) |
| 2726 |
self.assertLess(len(errors(run.errors)), 1) |
| 2727 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2728 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2729 |
self.rm_testdir() |
| 2730 |
def test_64842(self): |
| 2731 |
""" unzzip-mem -l $(CVE).zip """ |
| 2732 |
tmpdir = self.testdir() |
| 2733 |
filename = self.zip_CVE_2018_14 |
| 2734 |
file_url = self.url_CVE_2018_14 |
| 2735 |
if not download_raw(file_url, filename, tmpdir): |
| 2736 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2737 |
exe = self.bins("unzzip-mem") |
| 2738 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2739 |
returncodes = [0]) |
| 2740 |
self.assertLess(len(run.output), 1) |
| 2741 |
# |
| 2742 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2743 |
returncodes = [0]) |
| 2744 |
self.assertLess(len(run.output), 30) |
| 2745 |
self.assertLess(len(errors(run.errors)), 10) |
| 2746 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2747 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2748 |
self.rm_testdir() |
| 2749 |
def test_64843(self): |
| 2750 |
""" unzzip-mix -l $(CVE).zip """ |
| 2751 |
tmpdir = self.testdir() |
| 2752 |
filename = self.zip_CVE_2018_14 |
| 2753 |
file_url = self.url_CVE_2018_14 |
| 2754 |
if not download_raw(file_url, filename, tmpdir): |
| 2755 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2756 |
exe = self.bins("unzzip-mix") |
| 2757 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2758 |
returncodes = [0, 2]) |
| 2759 |
self.assertLess(len(run.output), 1) |
| 2760 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2761 |
# |
| 2762 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2763 |
returncodes = [0,2]) |
| 2764 |
self.assertLess(len(run.output), 30) |
| 2765 |
self.assertLess(len(errors(run.errors)), 10) |
| 2766 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2767 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2768 |
self.rm_testdir() |
| 2769 |
def test_64844(self): |
| 2770 |
""" unzzip-zap -l $(CVE).zip """ |
| 2771 |
tmpdir = self.testdir() |
| 2772 |
filename = self.zip_CVE_2018_14 |
| 2773 |
file_url = self.url_CVE_2018_14 |
| 2774 |
if not download_raw(file_url, filename, tmpdir): |
| 2775 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2776 |
exe = self.bins("unzzip") |
| 2777 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2778 |
returncodes = [0, 3]) |
| 2779 |
self.assertLess(len(run.output), 1) |
| 2780 |
self.assertLess(len(errors(run.errors)), 200) |
| 2781 |
self.assertErrorMessage(run.errors, 0) |
| 2782 |
# |
| 2783 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2784 |
returncodes = [0,3]) |
| 2785 |
self.assertLess(len(run.output), 30) |
| 2786 |
self.assertLess(len(errors(run.errors)), 10) |
| 2787 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2788 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2789 |
self.rm_testdir() |
| 2790 |
def test_64848(self): |
| 2791 |
""" zzdir $(CVE).zip """ |
| 2792 |
tmpdir = self.testdir() |
| 2793 |
filename = self.zip_CVE_2018_14 |
| 2794 |
file_url = self.url_CVE_2018_14 |
| 2795 |
if not download_raw(file_url, filename, tmpdir): |
| 2796 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2797 |
exe = self.bins("zzdir") |
| 2798 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2799 |
returncodes = [1]) |
| 2800 |
self.assertLess(len(run.output), 1) |
| 2801 |
self.assertLess(len(errors(run.errors)), 200) |
| 2802 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2803 |
self.rm_testdir() |
| 2804 |
def test_64849(self): |
| 2805 |
""" check $(CVE).zip """ |
| 2806 |
tmpdir = self.testdir() |
| 2807 |
filename = self.zip_CVE_2018_14 |
| 2808 |
file_url = self.url_CVE_2018_14 |
| 2809 |
if not download_raw(file_url, filename, tmpdir): |
| 2810 |
self.skipTest("no zip_CVE_2018_14 available: " + filename) |
| 2811 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2812 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2813 |
self.assertEqual(size, 56) |
| 2814 |
|
| 2815 |
url_CVE_2018_15 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2816 |
zip_CVE_2018_15 = "zziplib_0-13-67_unzip-mem_memory-alignment-errors_zzip_disk_findfirst.zip" |
| 2817 |
def test_65400(self): |
| 2818 |
""" info unzip -l $(CVE).zip """ |
| 2819 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2820 |
tmpdir = self.testdir() |
| 2821 |
filename = self.zip_CVE_2018_15 |
| 2822 |
file_url = self.url_CVE_2018_15 |
| 2823 |
if not download_raw(file_url, filename, tmpdir): |
| 2824 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2825 |
exe = self.bins("unzip") |
| 2826 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2827 |
returncodes = [2]) |
| 2828 |
self.assertIn("reported length of central directory", run.errors) |
| 2829 |
self.assertLess(len(run.output), 300) |
| 2830 |
self.assertLess(len(errors(run.errors)), 800) |
| 2831 |
# |
| 2832 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2833 |
returncodes = [2]) |
| 2834 |
self.assertLess(len(run.output), 300) |
| 2835 |
self.assertLess(len(errors(run.errors)), 800) |
| 2836 |
self.assertIn('reported length of central directory', run.errors) |
| 2837 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2838 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2839 |
self.rm_testdir() |
| 2840 |
def test_65401(self): |
| 2841 |
""" unzzip-big -l $(CVE).zip """ |
| 2842 |
tmpdir = self.testdir() |
| 2843 |
filename = self.zip_CVE_2018_15 |
| 2844 |
file_url = self.url_CVE_2018_15 |
| 2845 |
if not download_raw(file_url, filename, tmpdir): |
| 2846 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2847 |
exe = self.bins("unzzip-big") |
| 2848 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2849 |
returncodes = [0]) |
| 2850 |
self.assertLess(len(run.output), 15) |
| 2851 |
self.assertLess(len(errors(run.errors)), 1) |
| 2852 |
# |
| 2853 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2854 |
returncodes = [0]) |
| 2855 |
self.assertLess(len(run.output), 30) |
| 2856 |
self.assertLess(len(errors(run.errors)), 1) |
| 2857 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2858 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2859 |
self.rm_testdir() |
| 2860 |
def test_65402(self): |
| 2861 |
""" unzzip-mem -l $(CVE).zip """ |
| 2862 |
tmpdir = self.testdir() |
| 2863 |
filename = self.zip_CVE_2018_15 |
| 2864 |
file_url = self.url_CVE_2018_15 |
| 2865 |
if not download_raw(file_url, filename, tmpdir): |
| 2866 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2867 |
exe = self.bins("unzzip-mem") |
| 2868 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2869 |
returncodes = [0]) |
| 2870 |
self.assertLess(len(run.output), 30) |
| 2871 |
self.assertLess(len(errors(run.errors)), 1) |
| 2872 |
# |
| 2873 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2874 |
returncodes = [0]) |
| 2875 |
self.assertLess(len(run.output), 30) |
| 2876 |
self.assertLess(len(errors(run.errors)), 10) |
| 2877 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2878 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2879 |
self.rm_testdir() |
| 2880 |
def test_65403(self): |
| 2881 |
""" unzzip-mix -l $(CVE).zip """ |
| 2882 |
tmpdir = self.testdir() |
| 2883 |
filename = self.zip_CVE_2018_15 |
| 2884 |
file_url = self.url_CVE_2018_15 |
| 2885 |
if not download_raw(file_url, filename, tmpdir): |
| 2886 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2887 |
exe = self.bins("unzzip-mix") |
| 2888 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2889 |
returncodes = [0,2]) |
| 2890 |
self.assertLess(len(run.output), 1) |
| 2891 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 2892 |
# |
| 2893 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2894 |
returncodes = [0,2]) |
| 2895 |
self.assertLess(len(run.output), 30) |
| 2896 |
self.assertLess(len(errors(run.errors)), 10) |
| 2897 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2898 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2899 |
self.rm_testdir() |
| 2900 |
def test_65404(self): |
| 2901 |
""" unzzip-zap -l $(CVE).zip """ |
| 2902 |
tmpdir = self.testdir() |
| 2903 |
filename = self.zip_CVE_2018_15 |
| 2904 |
file_url = self.url_CVE_2018_15 |
| 2905 |
if not download_raw(file_url, filename, tmpdir): |
| 2906 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2907 |
exe = self.bins("unzzip") |
| 2908 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2909 |
returncodes = [0, 3]) |
| 2910 |
self.assertLess(len(run.output), 1) |
| 2911 |
self.assertLess(len(errors(run.errors)), 200) |
| 2912 |
self.assertErrorMessage(run.errors, 0) |
| 2913 |
# |
| 2914 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2915 |
returncodes = [0,3]) |
| 2916 |
self.assertLess(len(run.output), 30) |
| 2917 |
self.assertLess(len(errors(run.errors)), 10) |
| 2918 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2919 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2920 |
self.rm_testdir() |
| 2921 |
def test_65409(self): |
| 2922 |
""" check $(CVE).zip """ |
| 2923 |
tmpdir = self.testdir() |
| 2924 |
filename = self.zip_CVE_2018_15 |
| 2925 |
file_url = self.url_CVE_2018_15 |
| 2926 |
if not download_raw(file_url, filename, tmpdir): |
| 2927 |
self.skipTest("no zip_CVE_2018_15 available: " + filename) |
| 2928 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 2929 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 2930 |
self.assertEqual(size, 141) |
| 2931 |
|
| 2932 |
url_CVE_2018_16 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 2933 |
zip_CVE_2018_16 = "zziplib_0-13-67_unzzip_memory-aligment-errors___zzip_fetch_disk_trailer.zip" |
| 2934 |
def test_65410(self): |
| 2935 |
""" info unzip -l $(CVE).zip """ |
| 2936 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 2937 |
tmpdir = self.testdir() |
| 2938 |
filename = self.zip_CVE_2018_16 |
| 2939 |
file_url = self.url_CVE_2018_16 |
| 2940 |
if not download_raw(file_url, filename, tmpdir): |
| 2941 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 2942 |
exe = self.bins("unzip") |
| 2943 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2944 |
returncodes = [0, 9]) |
| 2945 |
self.assertIn("End-of-central-directory signature not found", run.errors) |
| 2946 |
self.assertLess(len(run.output), 200) |
| 2947 |
self.assertLess(len(errors(run.errors)), 800) |
| 2948 |
# |
| 2949 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 2950 |
returncodes = [9]) |
| 2951 |
self.assertLess(len(run.output), 200) |
| 2952 |
self.assertLess(len(errors(run.errors)), 800) |
| 2953 |
self.assertIn('End-of-central-directory signature not found', run.errors) |
| 2954 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2955 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2956 |
self.rm_testdir() |
| 2957 |
def test_65411(self): |
| 2958 |
""" unzzip-big -l $(CVE).zip """ |
| 2959 |
tmpdir = self.testdir() |
| 2960 |
filename = self.zip_CVE_2018_16 |
| 2961 |
file_url = self.url_CVE_2018_16 |
| 2962 |
if not download_raw(file_url, filename, tmpdir): |
| 2963 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 2964 |
exe = self.bins("unzzip-big") |
| 2965 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2966 |
returncodes = [0]) |
| 2967 |
self.assertLess(len(run.output), 1) |
| 2968 |
self.assertLess(len(errors(run.errors)), 1) |
| 2969 |
# |
| 2970 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2971 |
returncodes = [0]) |
| 2972 |
self.assertLess(len(run.output), 30) |
| 2973 |
self.assertLess(len(errors(run.errors)), 1) |
| 2974 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2975 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2976 |
self.rm_testdir() |
| 2977 |
def test_65412(self): |
| 2978 |
""" unzzip-mem -l $(CVE).zip """ |
| 2979 |
tmpdir = self.testdir() |
| 2980 |
filename = self.zip_CVE_2018_16 |
| 2981 |
file_url = self.url_CVE_2018_16 |
| 2982 |
if not download_raw(file_url, filename, tmpdir): |
| 2983 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 2984 |
exe = self.bins("unzzip-mem") |
| 2985 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 2986 |
returncodes = [0]) |
| 2987 |
self.assertLess(len(run.output), 1) |
| 2988 |
self.assertLess(len(errors(run.errors)), 1) |
| 2989 |
# |
| 2990 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 2991 |
returncodes = [0]) |
| 2992 |
self.assertLess(len(run.output), 30) |
| 2993 |
self.assertLess(len(errors(run.errors)), 10) |
| 2994 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 2995 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 2996 |
self.rm_testdir() |
| 2997 |
def test_65413(self): |
| 2998 |
""" unzzip-mix -l $(CVE).zip """ |
| 2999 |
tmpdir = self.testdir() |
| 3000 |
filename = self.zip_CVE_2018_16 |
| 3001 |
file_url = self.url_CVE_2018_16 |
| 3002 |
if not download_raw(file_url, filename, tmpdir): |
| 3003 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 3004 |
exe = self.bins("unzzip-mix") |
| 3005 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3006 |
returncodes = [0,2]) |
| 3007 |
self.assertLess(len(run.output), 1) |
| 3008 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3009 |
# |
| 3010 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3011 |
returncodes = [0,2]) |
| 3012 |
self.assertLess(len(run.output), 30) |
| 3013 |
self.assertLess(len(errors(run.errors)), 10) |
| 3014 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3015 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3016 |
self.rm_testdir() |
| 3017 |
def test_65414(self): |
| 3018 |
""" unzzip-zap -l $(CVE).zip """ |
| 3019 |
tmpdir = self.testdir() |
| 3020 |
filename = self.zip_CVE_2018_16 |
| 3021 |
file_url = self.url_CVE_2018_16 |
| 3022 |
if not download_raw(file_url, filename, tmpdir): |
| 3023 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 3024 |
exe = self.bins("unzzip") |
| 3025 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3026 |
returncodes = [0, 3]) |
| 3027 |
self.assertLess(len(run.output), 1) |
| 3028 |
self.assertLess(len(errors(run.errors)), 200) |
| 3029 |
self.assertErrorMessage(run.errors, 0) |
| 3030 |
# |
| 3031 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3032 |
returncodes = [0,3]) |
| 3033 |
self.assertLess(len(run.output), 30) |
| 3034 |
self.assertLess(len(errors(run.errors)), 10) |
| 3035 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3036 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3037 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3038 |
# |
| 3039 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3040 |
returncodes = [0,3]) |
| 3041 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3042 |
self.rm_testdir() |
| 3043 |
def test_65419(self): |
| 3044 |
""" check $(CVE).zip """ |
| 3045 |
tmpdir = self.testdir() |
| 3046 |
filename = self.zip_CVE_2018_16 |
| 3047 |
file_url = self.url_CVE_2018_16 |
| 3048 |
if not download_raw(file_url, filename, tmpdir): |
| 3049 |
self.skipTest("no zip_CVE_2018_16 available: " + filename) |
| 3050 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3051 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3052 |
self.assertEqual(size, 124) |
| 3053 |
|
| 3054 |
url_CVE_2018_17 = "https://github.com/ProbeFuzzer/poc/blob/master/zziplib" |
| 3055 |
zip_CVE_2018_17 = "zziplib_0-13-67_unzip-mem_memory-alignment-errors_zzip_disk_findfirst_64.zip" |
| 3056 |
def test_65420(self): |
| 3057 |
""" info unzip -l $(CVE).zip """ |
| 3058 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3059 |
tmpdir = self.testdir() |
| 3060 |
filename = self.zip_CVE_2018_17 |
| 3061 |
file_url = self.url_CVE_2018_17 |
| 3062 |
if not download_raw(file_url, filename, tmpdir): |
| 3063 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3064 |
exe = self.bins("unzip") |
| 3065 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3066 |
returncodes = [0, 9]) |
| 3067 |
self.assertIn("End-of-central-directory signature not found", run.errors) |
| 3068 |
self.assertLess(len(run.output), 200) |
| 3069 |
self.assertLess(len(errors(run.errors)), 800) |
| 3070 |
# |
| 3071 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3072 |
returncodes = [9]) |
| 3073 |
self.assertLess(len(run.output), 200) |
| 3074 |
self.assertLess(len(errors(run.errors)), 800) |
| 3075 |
self.assertIn('End-of-central-directory signature not found', run.errors) |
| 3076 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3077 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3078 |
self.rm_testdir() |
| 3079 |
def test_65421(self): |
| 3080 |
""" unzzip-big -l $(CVE).zip """ |
| 3081 |
tmpdir = self.testdir() |
| 3082 |
filename = self.zip_CVE_2018_17 |
| 3083 |
file_url = self.url_CVE_2018_17 |
| 3084 |
if not download_raw(file_url, filename, tmpdir): |
| 3085 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3086 |
exe = self.bins("unzzip-big") |
| 3087 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3088 |
returncodes = [0]) |
| 3089 |
self.assertLess(len(run.output), 1) |
| 3090 |
# |
| 3091 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3092 |
returncodes = [0]) |
| 3093 |
self.assertLess(len(run.output), 30) |
| 3094 |
self.assertLess(len(errors(run.errors)), 1) |
| 3095 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3096 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3097 |
self.rm_testdir() |
| 3098 |
def test_65422(self): |
| 3099 |
""" unzzip-mem -l $(CVE).zip """ |
| 3100 |
tmpdir = self.testdir() |
| 3101 |
filename = self.zip_CVE_2018_17 |
| 3102 |
file_url = self.url_CVE_2018_17 |
| 3103 |
if not download_raw(file_url, filename, tmpdir): |
| 3104 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3105 |
exe = self.bins("unzzip-mem") |
| 3106 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3107 |
returncodes = [0]) |
| 3108 |
self.assertLess(len(run.output), 50) |
| 3109 |
self.assertLess(len(errors(run.errors)), 1) |
| 3110 |
# |
| 3111 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3112 |
returncodes = [0]) |
| 3113 |
self.assertLess(len(run.output), 30) |
| 3114 |
self.assertLess(len(errors(run.errors)), 10) |
| 3115 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3116 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3117 |
# |
| 3118 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3119 |
returncodes = [0]) |
| 3120 |
# self.rm_testdir() |
| 3121 |
def test_65423(self): |
| 3122 |
""" unzzip-mix -l $(CVE).zip """ |
| 3123 |
tmpdir = self.testdir() |
| 3124 |
filename = self.zip_CVE_2018_17 |
| 3125 |
file_url = self.url_CVE_2018_17 |
| 3126 |
if not download_raw(file_url, filename, tmpdir): |
| 3127 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3128 |
exe = self.bins("unzzip-mix") |
| 3129 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3130 |
returncodes = [0,2]) |
| 3131 |
self.assertLess(len(run.output), 1) |
| 3132 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3133 |
# |
| 3134 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3135 |
returncodes = [0,2]) |
| 3136 |
self.assertLess(len(run.output), 30) |
| 3137 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3138 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3139 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3140 |
self.rm_testdir() |
| 3141 |
def test_65424(self): |
| 3142 |
""" unzzip-zap -l $(CVE).zip """ |
| 3143 |
tmpdir = self.testdir() |
| 3144 |
filename = self.zip_CVE_2018_17 |
| 3145 |
file_url = self.url_CVE_2018_17 |
| 3146 |
if not download_raw(file_url, filename, tmpdir): |
| 3147 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3148 |
exe = self.bins("unzzip") |
| 3149 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3150 |
returncodes = [0, 3]) |
| 3151 |
self.assertLess(len(run.output), 1) |
| 3152 |
self.assertLess(len(errors(run.errors)), 200) |
| 3153 |
self.assertErrorMessage(run.errors, 0) |
| 3154 |
# |
| 3155 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3156 |
returncodes = [0,3]) |
| 3157 |
self.assertLess(len(run.output), 30) |
| 3158 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3159 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3160 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3161 |
self.rm_testdir() |
| 3162 |
def test_65429(self): |
| 3163 |
""" check $(CVE).zip """ |
| 3164 |
tmpdir = self.testdir() |
| 3165 |
filename = self.zip_CVE_2018_17 |
| 3166 |
file_url = self.url_CVE_2018_17 |
| 3167 |
if not download_raw(file_url, filename, tmpdir): |
| 3168 |
self.skipTest("no zip_CVE_2018_17 available: " + filename) |
| 3169 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3170 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3171 |
self.assertEqual(size, 360) |
| 3172 |
|
| 3173 |
|
| 3174 |
url_CVE_2018_42 = "https://github.com/fantasy7082/image_test/blob/master" |
| 3175 |
zip_CVE_2018_42 = "c006-unknown-add-main" |
| 3176 |
def test_65430(self): |
| 3177 |
""" info unzip -l $(CVE).zip """ |
| 3178 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3179 |
tmpdir = self.testdir() |
| 3180 |
filename = self.zip_CVE_2018_42 |
| 3181 |
file_url = self.url_CVE_2018_42 |
| 3182 |
if not download_raw(file_url, filename, tmpdir): |
| 3183 |
self.skipTest("no zip_CVE_2018_42 available: " + filename) |
| 3184 |
exe = self.bins("unzip") |
| 3185 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3186 |
returncodes = [3]) |
| 3187 |
self.assertIn("missing 18 bytes in zipfile", run.errors) |
| 3188 |
self.assertLess(len(run.output), 200) |
| 3189 |
self.assertLess(len(errors(run.errors)), 800) |
| 3190 |
# |
| 3191 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3192 |
returncodes = [3]) |
| 3193 |
self.assertLess(len(run.output), 200) |
| 3194 |
self.assertLess(len(errors(run.errors)), 800) |
| 3195 |
self.assertIn("missing 18 bytes in zipfile", run.errors) |
| 3196 |
self.assertIn('expected central file header signature not found', run.errors) |
| 3197 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3198 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3199 |
self.rm_testdir() |
| 3200 |
def test_65431(self): |
| 3201 |
""" zzdir $(CVE).zip """ |
| 3202 |
tmpdir = self.testdir() |
| 3203 |
filename = self.zip_CVE_2018_42 |
| 3204 |
file_url = self.url_CVE_2018_42 |
| 3205 |
if not download_raw(file_url, filename, tmpdir): |
| 3206 |
self.skipTest("no zip_CVE_2018_42 available: " + filename) |
| 3207 |
exe = self.bins("zzdir") |
| 3208 |
run = shell("{exe} {tmpdir}/{filename} ".format(**locals()), |
| 3209 |
returncodes = [0]) |
| 3210 |
logg.info("OUT %s", run.output) |
| 3211 |
logg.info("ERR %s", run.errors) |
| 3212 |
self.assertIn(" zipped ", run.output) |
| 3213 |
self.rm_testdir() |
| 3214 |
|
| 3215 |
url_CVE_2018_43 = "https://github.com/fantasy7082/image_test/blob/master" |
| 3216 |
zip_CVE_2018_43 = "c008-main-unknown-de" |
| 3217 |
def test_65440(self): |
| 3218 |
""" info unzip -l $(CVE).zip """ |
| 3219 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3220 |
tmpdir = self.testdir() |
| 3221 |
filename = self.zip_CVE_2018_43 |
| 3222 |
file_url = self.url_CVE_2018_43 |
| 3223 |
if not download_raw(file_url, filename, tmpdir): |
| 3224 |
self.skipTest("no zip_CVE_2018_43 available: " + filename) |
| 3225 |
exe = self.bins("unzip") |
| 3226 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3227 |
returncodes = [3]) |
| 3228 |
self.assertIn("missing 18 bytes in zipfile", run.errors) |
| 3229 |
self.assertGreater(len(run.output), 30) |
| 3230 |
self.assertGreater(len(errors(run.errors)), 1) |
| 3231 |
self.assertLess(len(run.output), 500) |
| 3232 |
self.assertLess(len(errors(run.errors)), 800) |
| 3233 |
# |
| 3234 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3235 |
returncodes = [3]) |
| 3236 |
self.assertGreater(len(run.output), 30) |
| 3237 |
self.assertGreater(len(errors(run.errors)), 1) |
| 3238 |
self.assertLess(len(run.output), 400) |
| 3239 |
self.assertLess(len(errors(run.errors)), 800) |
| 3240 |
self.assertIn("missing 18 bytes in zipfile", run.errors) |
| 3241 |
self.assertIn('expected central file header signature not found', run.errors) |
| 3242 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3243 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3244 |
self.rm_testdir() |
| 3245 |
def test_65441(self): |
| 3246 |
""" zzdir $(CVE).zip """ |
| 3247 |
tmpdir = self.testdir() |
| 3248 |
filename = self.zip_CVE_2018_43 |
| 3249 |
file_url = self.url_CVE_2018_43 |
| 3250 |
if not download_raw(file_url, filename, tmpdir): |
| 3251 |
self.skipTest("no zip_CVE_2018_43 available: " + filename) |
| 3252 |
exe = self.bins("zzdir") |
| 3253 |
run = shell("{exe} {tmpdir}/{filename} ".format(**locals()), |
| 3254 |
returncodes = [0]) |
| 3255 |
logg.info("OUT %s", run.output) |
| 3256 |
logg.info("ERR %s", run.errors) |
| 3257 |
self.assertIn(" zipped ", run.output) |
| 3258 |
self.rm_testdir() |
| 3259 |
|
| 3260 |
url_CVE_2018_27 = "https://github.com/ret2libc/---provided-by-email---" |
| 3261 |
zip_CVE_2018_27 = "poc_bypass_fix2.zip" |
| 3262 |
zip_CVE_2018_27_size = 56 |
| 3263 |
def test_65450(self): |
| 3264 |
""" info unzip -l $(CVE).zip """ |
| 3265 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3266 |
tmpdir = self.testdir() |
| 3267 |
filename = self.zip_CVE_2018_27 |
| 3268 |
file_url = self.url_CVE_2018_27 |
| 3269 |
filesize = self.zip_CVE_2018_27_size |
| 3270 |
if not download_raw(file_url, filename, tmpdir): |
| 3271 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3272 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3273 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3274 |
exe = self.bins("unzip") |
| 3275 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3276 |
returncodes = [0, 9]) |
| 3277 |
self.assertIn("End-of-central-directory signature not found", run.errors) |
| 3278 |
self.assertLess(len(run.output), 200) |
| 3279 |
self.assertLess(len(errors(run.errors)), 800) |
| 3280 |
# |
| 3281 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3282 |
returncodes = [9]) |
| 3283 |
self.assertLess(len(run.output), 200) |
| 3284 |
self.assertLess(len(errors(run.errors)), 800) |
| 3285 |
self.assertIn('End-of-central-directory signature not found', run.errors) |
| 3286 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3287 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3288 |
self.rm_testdir() |
| 3289 |
def test_65451(self): |
| 3290 |
""" unzzip-big -l $(CVE).zip """ |
| 3291 |
tmpdir = self.testdir() |
| 3292 |
filename = self.zip_CVE_2018_27 |
| 3293 |
file_url = self.url_CVE_2018_27 |
| 3294 |
filesize = self.zip_CVE_2018_27_size |
| 3295 |
if not download_raw(file_url, filename, tmpdir): |
| 3296 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3297 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3298 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3299 |
exe = self.bins("unzzip-big") |
| 3300 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3301 |
returncodes = [0]) |
| 3302 |
self.assertLess(len(run.output), 1) |
| 3303 |
# |
| 3304 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3305 |
returncodes = [0]) |
| 3306 |
self.assertLess(len(run.output), 30) |
| 3307 |
self.assertLess(len(errors(run.errors)), 1) |
| 3308 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3309 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3310 |
self.rm_testdir() |
| 3311 |
def test_65452(self): |
| 3312 |
""" unzzip-mem -l $(CVE).zip """ |
| 3313 |
tmpdir = self.testdir() |
| 3314 |
filename = self.zip_CVE_2018_27 |
| 3315 |
file_url = self.url_CVE_2018_27 |
| 3316 |
filesize = self.zip_CVE_2018_27_size |
| 3317 |
if not download_raw(file_url, filename, tmpdir): |
| 3318 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3319 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3320 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3321 |
exe = self.bins("unzzip-mem") |
| 3322 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3323 |
returncodes = [0]) |
| 3324 |
self.assertLess(len(run.output), 50) |
| 3325 |
self.assertLess(len(errors(run.errors)), 1) |
| 3326 |
# |
| 3327 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3328 |
returncodes = [0]) |
| 3329 |
self.assertLess(len(run.output), 30) |
| 3330 |
self.assertLess(len(errors(run.errors)), 10) |
| 3331 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3332 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3333 |
# |
| 3334 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3335 |
returncodes = [0]) |
| 3336 |
# self.rm_testdir() |
| 3337 |
def test_65453(self): |
| 3338 |
""" unzzip-mix -l $(CVE).zip """ |
| 3339 |
tmpdir = self.testdir() |
| 3340 |
filename = self.zip_CVE_2018_27 |
| 3341 |
file_url = self.url_CVE_2018_27 |
| 3342 |
filesize = self.zip_CVE_2018_27_size |
| 3343 |
if not download_raw(file_url, filename, tmpdir): |
| 3344 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3345 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3346 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3347 |
exe = self.bins("unzzip-mix") |
| 3348 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3349 |
returncodes = [0,2]) |
| 3350 |
self.assertLess(len(run.output), 1) |
| 3351 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3352 |
# |
| 3353 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3354 |
returncodes = [0,2]) |
| 3355 |
self.assertLess(len(run.output), 30) |
| 3356 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3357 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3358 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3359 |
self.rm_testdir() |
| 3360 |
def test_65454(self): |
| 3361 |
""" unzzip-zap -l $(CVE).zip """ |
| 3362 |
tmpdir = self.testdir() |
| 3363 |
filename = self.zip_CVE_2018_27 |
| 3364 |
file_url = self.url_CVE_2018_27 |
| 3365 |
filesize = self.zip_CVE_2018_27_size |
| 3366 |
if not download_raw(file_url, filename, tmpdir): |
| 3367 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3368 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3369 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3370 |
exe = self.bins("unzzip") |
| 3371 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3372 |
returncodes = [0, 3]) |
| 3373 |
self.assertLess(len(run.output), 1) |
| 3374 |
self.assertLess(len(errors(run.errors)), 200) |
| 3375 |
self.assertErrorMessage(run.errors, 0) |
| 3376 |
# |
| 3377 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3378 |
returncodes = [0,3]) |
| 3379 |
self.assertLess(len(run.output), 30) |
| 3380 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3381 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3382 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3383 |
self.rm_testdir() |
| 3384 |
def test_65459(self): |
| 3385 |
""" check $(CVE).zip """ |
| 3386 |
tmpdir = self.testdir() |
| 3387 |
filename = self.zip_CVE_2018_27 |
| 3388 |
file_url = self.url_CVE_2018_27 |
| 3389 |
filesize = self.zip_CVE_2018_27_size |
| 3390 |
if not download_raw(file_url, filename, tmpdir): |
| 3391 |
self.skipTest("no zip_CVE_2018_27 available: " + filename) |
| 3392 |
if ((os.path.getsize(os.path.join(tmpdir, filename)) != filesize)): |
| 3393 |
self.skipTest("zip for CVE_2018_27 is confidential: " + filename) |
| 3394 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3395 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3396 |
self.assertEqual(size, filesize) # 56 |
| 3397 |
|
| 3398 |
url_CVE_2018_41 = "https://github.com/fantasy7082/image_test/blob/master" |
| 3399 |
zip_CVE_2018_41 = "c005-bus-zzip_parse_root_directory" # CVE-2018-7726. |
| 3400 |
def test_65460(self): |
| 3401 |
""" info unzip -l $(CVE).zip """ |
| 3402 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3403 |
tmpdir = self.testdir() |
| 3404 |
filename = self.zip_CVE_2018_41 |
| 3405 |
file_url = self.url_CVE_2018_41 |
| 3406 |
if not download_raw(file_url, filename, tmpdir): |
| 3407 |
self.skipTest("no zip_CVE_2018_41 available: " + filename) |
| 3408 |
exe = self.bins("unzip") |
| 3409 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3410 |
returncodes = [0, 3]) |
| 3411 |
self.assertIn("missing 20 bytes in zipfile", run.errors) |
| 3412 |
self.assertLess(len(run.output), 200) |
| 3413 |
self.assertLess(len(errors(run.errors)), 800) |
| 3414 |
# |
| 3415 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3416 |
returncodes = [3]) |
| 3417 |
self.assertLess(len(run.output), 200) |
| 3418 |
self.assertLess(len(errors(run.errors)), 800) |
| 3419 |
self.assertIn("missing 20 bytes in zipfile", run.errors) |
| 3420 |
self.assertIn('attempt to seek before beginning of zipfile', run.errors) |
| 3421 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3422 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3423 |
self.rm_testdir() |
| 3424 |
def test_65461(self): |
| 3425 |
""" zzdir $(CVE).zip """ |
| 3426 |
tmpdir = self.testdir() |
| 3427 |
filename = self.zip_CVE_2018_41 |
| 3428 |
file_url = self.url_CVE_2018_41 |
| 3429 |
if not download_raw(file_url, filename, tmpdir): |
| 3430 |
self.skipTest("no zip_CVE_2018_41 available: " + filename) |
| 3431 |
exe = self.bins("zzdir") |
| 3432 |
run = shell("{exe} {tmpdir}/{filename} ".format(**locals()), |
| 3433 |
returncodes = [1]) |
| 3434 |
logg.info("OUT %s", run.output) |
| 3435 |
logg.info("ERR %s", run.errors) |
| 3436 |
####### self.assertIn(" zipped ", run.output) |
| 3437 |
self.rm_testdir() |
| 3438 |
|
| 3439 |
url_CVE_2018_39 = "https://github.com/fantasy7082/image_test/blob/master" |
| 3440 |
zip_CVE_2018_39 = "003-unknow-def-zip" |
| 3441 |
def test_65470(self): |
| 3442 |
""" info unzip -l $(CVE).zip """ |
| 3443 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3444 |
tmpdir = self.testdir() |
| 3445 |
filename = self.zip_CVE_2018_39 |
| 3446 |
file_url = self.url_CVE_2018_39 |
| 3447 |
if not download_raw(file_url, filename, tmpdir): |
| 3448 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3449 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3450 |
exe = self.bins("unzip") |
| 3451 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3452 |
returncodes = [3]) |
| 3453 |
self.assertIn("missing 5123 bytes in zipfile", run.errors) |
| 3454 |
self.assertIn("expected central file header signature not found", run.errors) |
| 3455 |
self.assertLess(len(run.output), 400) |
| 3456 |
self.assertLess(len(errors(run.errors)), 800) |
| 3457 |
# |
| 3458 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3459 |
returncodes = [3]) |
| 3460 |
self.assertLess(len(run.output), 400) |
| 3461 |
self.assertLess(len(errors(run.errors)), 800) |
| 3462 |
self.assertIn("missing 5123 bytes in zipfile", run.errors) |
| 3463 |
self.assertIn("expected central file header signature not found", run.errors) |
| 3464 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3465 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3466 |
self.rm_testdir() |
| 3467 |
def test_65471(self): |
| 3468 |
""" unzzip-big -l $(CVE).zip """ |
| 3469 |
tmpdir = self.testdir() |
| 3470 |
filename = self.zip_CVE_2018_39 |
| 3471 |
file_url = self.url_CVE_2018_39 |
| 3472 |
if not download_raw(file_url, filename, tmpdir): |
| 3473 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3474 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3475 |
exe = self.bins("unzzip-big") |
| 3476 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3477 |
returncodes = [0]) |
| 3478 |
self.assertLess(len(run.output), 1) |
| 3479 |
# |
| 3480 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3481 |
returncodes = [0]) |
| 3482 |
self.assertLess(len(run.output), 30) |
| 3483 |
self.assertLess(len(errors(run.errors)), 1) |
| 3484 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3485 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3486 |
self.rm_testdir() |
| 3487 |
def test_65472(self): |
| 3488 |
""" unzzip-mem -l $(CVE).zip """ |
| 3489 |
tmpdir = self.testdir() |
| 3490 |
filename = self.zip_CVE_2018_39 |
| 3491 |
file_url = self.url_CVE_2018_39 |
| 3492 |
if not download_raw(file_url, filename, tmpdir): |
| 3493 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3494 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3495 |
exe = self.bins("unzzip-mem") |
| 3496 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3497 |
returncodes = [0]) |
| 3498 |
self.assertLess(len(run.output), 200) |
| 3499 |
self.assertLess(len(errors(run.errors)), 1) |
| 3500 |
# |
| 3501 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3502 |
returncodes = [0]) |
| 3503 |
self.assertLess(len(run.output), 200) |
| 3504 |
self.assertLess(len(errors(run.errors)), 10) |
| 3505 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3506 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3507 |
# |
| 3508 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3509 |
returncodes = [0]) |
| 3510 |
# self.rm_testdir() |
| 3511 |
def test_65473(self): |
| 3512 |
""" unzzip-mix -l $(CVE).zip """ |
| 3513 |
tmpdir = self.testdir() |
| 3514 |
filename = self.zip_CVE_2018_39 |
| 3515 |
file_url = self.url_CVE_2018_39 |
| 3516 |
if not download_raw(file_url, filename, tmpdir): |
| 3517 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3518 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3519 |
exe = self.bins("unzzip-mix") |
| 3520 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3521 |
returncodes = [0,2]) |
| 3522 |
self.assertLess(len(run.output), 1) |
| 3523 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3524 |
# |
| 3525 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3526 |
returncodes = [0,2]) |
| 3527 |
self.assertLess(len(run.output), 30) |
| 3528 |
self.assertErrorMessage(run.errors, errno.EILSEQ) |
| 3529 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3530 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3531 |
self.rm_testdir() |
| 3532 |
def test_65474(self): |
| 3533 |
""" unzzip-zap -l $(CVE).zip """ |
| 3534 |
tmpdir = self.testdir() |
| 3535 |
filename = self.zip_CVE_2018_39 |
| 3536 |
file_url = self.url_CVE_2018_39 |
| 3537 |
if not download_raw(file_url, filename, tmpdir): |
| 3538 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3539 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3540 |
exe = self.bins("unzzip") |
| 3541 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3542 |
returncodes = [0, 3]) |
| 3543 |
self.assertLess(len(run.output), 1) |
| 3544 |
self.assertLess(len(errors(run.errors)), 200) |
| 3545 |
self.assertErrorMessage(run.errors, 0) |
| 3546 |
# |
| 3547 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3548 |
returncodes = [0,3]) |
| 3549 |
self.assertLess(len(run.output), 30) |
| 3550 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3551 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3552 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3553 |
self.rm_testdir() |
| 3554 |
def test_65479(self): |
| 3555 |
""" check $(CVE).zip """ |
| 3556 |
tmpdir = self.testdir() |
| 3557 |
filename = self.zip_CVE_2018_39 |
| 3558 |
file_url = self.url_CVE_2018_39 |
| 3559 |
if not download_raw(file_url, filename, tmpdir): |
| 3560 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3561 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3562 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3563 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3564 |
self.assertEqual(size, 82347) |
| 3565 |
|
| 3566 |
url_CVE_2018_40 = "https://github.com/fantasy7082/image_test/blob/master" |
| 3567 |
zip_CVE_2018_40 = "002-mem-leaks-zip" |
| 3568 |
def test_65480(self): |
| 3569 |
""" info unzip -l $(CVE).zip """ |
| 3570 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3571 |
tmpdir = self.testdir() |
| 3572 |
filename = self.zip_CVE_2018_40 |
| 3573 |
file_url = self.url_CVE_2018_40 |
| 3574 |
if not download_raw(file_url, filename, tmpdir): |
| 3575 |
self.skipTest("no zip_CVE_2018_40 available: " + filename) |
| 3576 |
exe = self.bins("unzip") |
| 3577 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3578 |
returncodes = [3]) |
| 3579 |
self.assertIn("missing 21 bytes in zipfile", run.errors) |
| 3580 |
self.assertGreater(len(run.output), 20) |
| 3581 |
self.assertGreater(len(errors(run.errors)), 1) |
| 3582 |
self.assertLess(len(run.output), 2500) |
| 3583 |
self.assertLess(len(errors(run.errors)), 800) |
| 3584 |
# |
| 3585 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3586 |
returncodes = [3]) |
| 3587 |
self.assertGreater(len(run.output), 20) |
| 3588 |
self.assertGreater(len(errors(run.errors)), 1) |
| 3589 |
self.assertLess(len(run.output), 2500) |
| 3590 |
self.assertLess(len(errors(run.errors)), 800) |
| 3591 |
self.assertIn("missing 21 bytes in zipfile", run.errors) |
| 3592 |
self.assertIn('expected central file header signature not found', run.errors) |
| 3593 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3594 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3595 |
self.rm_testdir() |
| 3596 |
def test_65482(self): |
| 3597 |
""" unzzip-mem -l $(CVE).zip """ |
| 3598 |
tmpdir = self.testdir() |
| 3599 |
filename = self.zip_CVE_2018_40 |
| 3600 |
file_url = self.url_CVE_2018_40 |
| 3601 |
if not download_raw(file_url, filename, tmpdir): |
| 3602 |
self.skipTest("no zip_CVE_2018_40 available: " + filename) |
| 3603 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3604 |
exe = self.bins("unzzip-mem") |
| 3605 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3606 |
returncodes = [0]) |
| 3607 |
self.assertLess(len(run.output), 1500) |
| 3608 |
self.assertLess(len(errors(run.errors)), 1) |
| 3609 |
# |
| 3610 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3611 |
returncodes = [0]) |
| 3612 |
self.assertLess(len(run.output), 1500) |
| 3613 |
self.assertLess(len(errors(run.errors)), 10) |
| 3614 |
# self.assertEqual(os.path.getsize(tmpdir+"/test"), 3) |
| 3615 |
self.assertFalse(os.path.exists(tmpdir+"/test")) |
| 3616 |
# |
| 3617 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3618 |
returncodes = [0]) |
| 3619 |
self.rm_testdir() |
| 3620 |
|
| 3621 |
url_CVE_2018_17828 = "https://github.com/gdraheim/zziplib/files/2415382" |
| 3622 |
zip_CVE_2018_17828 = "evil.zip" |
| 3623 |
def test_65484(self): |
| 3624 |
""" extract file with "../" in the pathname [CVE-2018-17828] """ |
| 3625 |
tmpdir = self.testdir() |
| 3626 |
filename = self.zip_CVE_2018_17828 |
| 3627 |
file_url = self.url_CVE_2018_17828 |
| 3628 |
if not download_raw(file_url, filename, tmpdir): |
| 3629 |
self.skipTest("no zip_CVE_2018_40 available: " + filename) |
| 3630 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3631 |
exe = self.bins("unzzip-mem") |
| 3632 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3633 |
returncodes = [0, 80]) |
| 3634 |
self.assertLess(len(run.output), 500) |
| 3635 |
self.assertLess(len(errors(run.errors)), 1) |
| 3636 |
# |
| 3637 |
workdir = tmpdir + "/d1/d2" |
| 3638 |
os.makedirs(workdir) |
| 3639 |
run = shell("cd {workdir} && ../../../{exe} ../../{filename} ".format(**locals()), |
| 3640 |
returncodes = [0]) |
| 3641 |
self.assertLess(len(run.output), 500) |
| 3642 |
self.assertEqual(len(errors(run.errors)), 1) |
| 3643 |
self.assertFalse(os.path.exists(tmpdir+"/test/evil.conf")) |
| 3644 |
self.assertTrue(os.path.exists(workdir+"/test/evil.conf")) |
| 3645 |
self.rm_testdir() |
| 3646 |
|
| 3647 |
def test_65485_list_verbose_compressed_with_directory(self): |
| 3648 |
""" verbously list a zipfile containing directories """ |
| 3649 |
chdir = "chdir" |
| 3650 |
if not exeext: chdir = "cd" |
| 3651 |
tmpdir = self.testdir() |
| 3652 |
workdir = tmpdir + "/d" |
| 3653 |
zipname = "ZIPfile" |
| 3654 |
os.makedirs(workdir) |
| 3655 |
f= open(tmpdir + "/d/file","w+") |
| 3656 |
for i in range(10): |
| 3657 |
f.write("This is line %d\r\n" % (i+1)) |
| 3658 |
f.close() |
| 3659 |
# create the ZIPfile |
| 3660 |
mkzip=self.bins("mkzip") |
| 3661 |
run = shell("{chdir} {tmpdir} && {mkzip} -9 {zipname}.zip d".format(**locals())) |
| 3662 |
self.assertFalse(run.returncode) |
| 3663 |
# list the ZIPfile |
| 3664 |
exe=self.bins("unzip-mem"); |
| 3665 |
run = shell("{chdir} {tmpdir} && ../{exe} -v {zipname}.zip".format(**locals()), returncodes = [0,-8]) |
| 3666 |
logg.error("FIXME: unzip-mem test_65485 is not solved") |
| 3667 |
self.skipTest("FIXME: not solved") |
| 3668 |
self.assertFalse(run.returncode) |
| 3669 |
self.rm_testdir() |
| 3670 |
|
| 3671 |
url_CVE_2020_04 = "https://github.com/gdraheim/zziplib/files/5340201" |
| 3672 |
zip_CVE_2020_04 = "2020_10_OutagesPUReasons.zip" |
| 3673 |
def test_65570(self): |
| 3674 |
""" info unzip -l $(CVE).zip """ |
| 3675 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3676 |
tmpdir = self.testdir() |
| 3677 |
filename = self.zip_CVE_2020_04 |
| 3678 |
file_url = self.url_CVE_2020_04 |
| 3679 |
if not download_raw(file_url, filename, tmpdir): |
| 3680 |
self.skipTest("no zip_CVE_2018_39 available: " + filename) |
| 3681 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3682 |
exe = self.bins("unzip") |
| 3683 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3684 |
returncodes = [0]) |
| 3685 |
# |
| 3686 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3687 |
returncodes = [0]) |
| 3688 |
self.assertEqual(os.path.getsize(tmpdir+"/2020_10_OutagesPUReasons.csv"), 2590160) |
| 3689 |
self.rm_testdir() |
| 3690 |
@unittest.expectedFailure |
| 3691 |
def test_65571(self): |
| 3692 |
""" unzzip-big -l $(CVE).zip """ |
| 3693 |
tmpdir = self.testdir() |
| 3694 |
filename = self.zip_CVE_2020_04 |
| 3695 |
file_url = self.url_CVE_2020_04 |
| 3696 |
if not download_raw(file_url, filename, tmpdir): |
| 3697 |
self.skipTest("no zip_CVE_2020_04 available: " + filename) |
| 3698 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3699 |
exe = self.bins("unzzip-big") |
| 3700 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3701 |
returncodes = [0]) |
| 3702 |
# |
| 3703 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3704 |
returncodes = [0]) |
| 3705 |
self.assertEqual(os.path.getsize(tmpdir+"/2020_10_OutagesPUReasons.csv"), 2590160) |
| 3706 |
self.rm_testdir() |
| 3707 |
@unittest.expectedFailure |
| 3708 |
def test_65572(self): |
| 3709 |
""" unzzip-mem -l $(CVE).zip """ |
| 3710 |
tmpdir = self.testdir() |
| 3711 |
filename = self.zip_CVE_2020_04 |
| 3712 |
file_url = self.url_CVE_2020_04 |
| 3713 |
if not download_raw(file_url, filename, tmpdir): |
| 3714 |
self.skipTest("no zip_CVE_2020_04 available: " + filename) |
| 3715 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3716 |
exe = self.bins("unzzip-mem") |
| 3717 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3718 |
returncodes = [0]) |
| 3719 |
self.assertLess(len(run.output), 1) |
| 3720 |
# self.assertEqual(len(errors(run.errors)), 1) |
| 3721 |
# |
| 3722 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3723 |
returncodes = [0]) |
| 3724 |
self.assertLess(len(run.output), 1) |
| 3725 |
self.assertEqual(os.path.getsize(tmpdir+"/2020_10_OutagesPUReasons.csv"), 2590160) |
| 3726 |
# |
| 3727 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3728 |
returncodes = [0]) |
| 3729 |
self.rm_testdir() |
| 3730 |
@unittest.expectedFailure |
| 3731 |
def test_65573(self): |
| 3732 |
""" unzzip-mix -l $(CVE).zip """ |
| 3733 |
tmpdir = self.testdir() |
| 3734 |
filename = self.zip_CVE_2020_04 |
| 3735 |
file_url = self.url_CVE_2020_04 |
| 3736 |
if not download_raw(file_url, filename, tmpdir): |
| 3737 |
self.skipTest("no zip_CVE_2020_04 available: " + filename) |
| 3738 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3739 |
exe = self.bins("unzzip-mix") |
| 3740 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3741 |
returncodes = [0]) |
| 3742 |
# |
| 3743 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3744 |
returncodes = [0,2]) |
| 3745 |
self.assertLess(len(run.output), 30) |
| 3746 |
self.assertEqual(os.path.getsize(tmpdir+"/2020_10_OutagesPUReasons.csv"), 2590160) |
| 3747 |
self.rm_testdir() |
| 3748 |
@unittest.expectedFailure |
| 3749 |
def test_65574(self): |
| 3750 |
""" unzzip-zap -l $(CVE).zip """ |
| 3751 |
tmpdir = self.testdir() |
| 3752 |
filename = self.zip_CVE_2020_04 |
| 3753 |
file_url = self.url_CVE_2020_04 |
| 3754 |
if not download_raw(file_url, filename, tmpdir): |
| 3755 |
self.skipTest("no zip_CVE_2020_04 available: " + filename) |
| 3756 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3757 |
exe = self.bins("unzzip") |
| 3758 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3759 |
returncodes = [0]) |
| 3760 |
# |
| 3761 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3762 |
returncodes = [0]) |
| 3763 |
self.assertEqual(os.path.getsize(tmpdir+"/2020_10_OutagesPUReasons.csv"), 2590160) |
| 3764 |
self.rm_testdir() |
| 3765 |
def test_65579(self): |
| 3766 |
""" check $(CVE).zip """ |
| 3767 |
tmpdir = self.testdir() |
| 3768 |
filename = self.zip_CVE_2020_04 |
| 3769 |
file_url = self.url_CVE_2020_04 |
| 3770 |
if not download_raw(file_url, filename, tmpdir): |
| 3771 |
self.skipTest("no zip_CVE_2020_04 available: " + filename) |
| 3772 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3773 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3774 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3775 |
self.assertEqual(size, 171344) |
| 3776 |
|
| 3777 |
|
| 3778 |
url_CVE_2019_69 = "https://github.com/gdraheim/zziplib/files/3001317" |
| 3779 |
zip_CVE_2019_69 = "zip_poc.zip" |
| 3780 |
def test_65670(self): |
| 3781 |
""" info unzip -l $(CVE).zip """ |
| 3782 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3783 |
tmpdir = self.testdir() |
| 3784 |
filename = self.zip_CVE_2019_69 |
| 3785 |
file_url = self.url_CVE_2019_69 |
| 3786 |
if not download_raw(file_url, filename, tmpdir): |
| 3787 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3788 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3789 |
exe = self.bins("unzip") |
| 3790 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3791 |
returncodes = [2]) |
| 3792 |
self.assertTrue(greps(run.errors, "missing 6 bytes in zipfile")) |
| 3793 |
# |
| 3794 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3795 |
returncodes = [3]) |
| 3796 |
self.rm_testdir() |
| 3797 |
def test_65671(self): |
| 3798 |
""" unzzip-big -l $(CVE).zip """ |
| 3799 |
tmpdir = self.testdir() |
| 3800 |
filename = self.zip_CVE_2019_69 |
| 3801 |
file_url = self.url_CVE_2019_69 |
| 3802 |
if not download_raw(file_url, filename, tmpdir): |
| 3803 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3804 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3805 |
exe = self.bins("unzzip-big") |
| 3806 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3807 |
returncodes = [0]) |
| 3808 |
# |
| 3809 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3810 |
returncodes = [1]) |
| 3811 |
self.rm_testdir() |
| 3812 |
def test_65672(self): |
| 3813 |
""" unzzip-mem -l $(CVE).zip """ |
| 3814 |
tmpdir = self.testdir() |
| 3815 |
filename = self.zip_CVE_2019_69 |
| 3816 |
file_url = self.url_CVE_2019_69 |
| 3817 |
if not download_raw(file_url, filename, tmpdir): |
| 3818 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3819 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3820 |
exe = self.bins("unzzip-mem") |
| 3821 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3822 |
returncodes = [0]) |
| 3823 |
# self.assertLess(len(run.output), 1) |
| 3824 |
# self.assertEqual(len(errors(run.errors)), 1) |
| 3825 |
# |
| 3826 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3827 |
returncodes = [0]) |
| 3828 |
self.assertLess(len(run.output), 1) |
| 3829 |
# |
| 3830 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3831 |
returncodes = [0]) |
| 3832 |
self.rm_testdir() |
| 3833 |
def test_65673(self): |
| 3834 |
""" unzzip-mix -l $(CVE).zip """ |
| 3835 |
tmpdir = self.testdir() |
| 3836 |
filename = self.zip_CVE_2019_69 |
| 3837 |
file_url = self.url_CVE_2019_69 |
| 3838 |
if not download_raw(file_url, filename, tmpdir): |
| 3839 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3840 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3841 |
exe = self.bins("unzzip-mix") |
| 3842 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3843 |
returncodes = [2]) |
| 3844 |
self.assertTrue(greps(run.errors, "Invalid or incomplete")) |
| 3845 |
# |
| 3846 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3847 |
returncodes = [2]) |
| 3848 |
# self.assertLess(len(run.output), 30) |
| 3849 |
self.assertTrue(greps(run.errors, "Invalid or incomplete")) |
| 3850 |
self.rm_testdir() |
| 3851 |
def test_65674(self): |
| 3852 |
""" unzzip-zap -l $(CVE).zip """ |
| 3853 |
tmpdir = self.testdir() |
| 3854 |
filename = self.zip_CVE_2019_69 |
| 3855 |
file_url = self.url_CVE_2019_69 |
| 3856 |
if not download_raw(file_url, filename, tmpdir): |
| 3857 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3858 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3859 |
exe = self.bins("unzzip") |
| 3860 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3861 |
returncodes = [3]) |
| 3862 |
# |
| 3863 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3864 |
returncodes = [3]) |
| 3865 |
self.assertTrue(greps(run.errors, "Zipfile corrupted")) |
| 3866 |
self.rm_testdir() |
| 3867 |
def test_65679(self): |
| 3868 |
""" check $(CVE).zip """ |
| 3869 |
tmpdir = self.testdir() |
| 3870 |
filename = self.zip_CVE_2019_69 |
| 3871 |
file_url = self.url_CVE_2019_69 |
| 3872 |
if not download_raw(file_url, filename, tmpdir): |
| 3873 |
self.skipTest("no zip_CVE_2019_69 available: " + filename) |
| 3874 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3875 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3876 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3877 |
self.assertEqual(size, 155) |
| 3878 |
|
| 3879 |
url_CVE_2019_70 = "https://github.com/gdraheim/zziplib/files/3006594" |
| 3880 |
zip_CVE_2019_70 = "POC.zip" |
| 3881 |
def test_65770(self): |
| 3882 |
""" info unzip -l $(CVE).zip """ |
| 3883 |
if unzip_skip: self.skipTest("skip tests using infozip 'unzip'") |
| 3884 |
tmpdir = self.testdir() |
| 3885 |
filename = self.zip_CVE_2019_70 |
| 3886 |
file_url = self.url_CVE_2019_70 |
| 3887 |
if not download_raw(file_url, filename, tmpdir): |
| 3888 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3889 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3890 |
exe = self.bins("unzip") |
| 3891 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3892 |
returncodes = [0]) |
| 3893 |
# |
| 3894 |
run = shell("cd {tmpdir} && {exe} -o {filename}".format(**locals()), |
| 3895 |
returncodes = [0]) |
| 3896 |
self.assertEqual(os.path.getsize(tmpdir+"/POC1"), 135) |
| 3897 |
self.assertEqual(os.path.getsize(tmpdir+"/POC2"), 135) |
| 3898 |
self.assertEqual(os.path.getsize(tmpdir+"/POC3"), 303) |
| 3899 |
self.rm_testdir() |
| 3900 |
def test_65771(self): |
| 3901 |
""" unzzip-big -l $(CVE).zip """ |
| 3902 |
tmpdir = self.testdir() |
| 3903 |
filename = self.zip_CVE_2019_70 |
| 3904 |
file_url = self.url_CVE_2019_70 |
| 3905 |
if not download_raw(file_url, filename, tmpdir): |
| 3906 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3907 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3908 |
exe = self.bins("unzzip-big") |
| 3909 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3910 |
returncodes = [0]) |
| 3911 |
# |
| 3912 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3913 |
returncodes = [0]) |
| 3914 |
self.assertEqual(os.path.getsize(tmpdir+"/POC1"), 135) |
| 3915 |
self.assertEqual(os.path.getsize(tmpdir+"/POC2"), 135) |
| 3916 |
self.assertEqual(os.path.getsize(tmpdir+"/POC3"), 303) |
| 3917 |
self.rm_testdir() |
| 3918 |
def test_65772(self): |
| 3919 |
""" unzzip-mem -l $(CVE).zip """ |
| 3920 |
tmpdir = self.testdir() |
| 3921 |
filename = self.zip_CVE_2019_70 |
| 3922 |
file_url = self.url_CVE_2019_70 |
| 3923 |
if not download_raw(file_url, filename, tmpdir): |
| 3924 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3925 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3926 |
exe = self.bins("unzzip-mem") |
| 3927 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3928 |
returncodes = [0]) |
| 3929 |
# self.assertLess(len(run.output), 1) |
| 3930 |
# self.assertEqual(len(errors(run.errors)), 1) |
| 3931 |
# |
| 3932 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3933 |
returncodes = [0]) |
| 3934 |
self.assertLess(len(run.output), 1) |
| 3935 |
self.assertEqual(os.path.getsize(tmpdir+"/POC1"), 135) |
| 3936 |
self.assertEqual(os.path.getsize(tmpdir+"/POC2"), 135) |
| 3937 |
self.assertEqual(os.path.getsize(tmpdir+"/POC3"), 303) |
| 3938 |
# |
| 3939 |
run = shell("cd {tmpdir} && ../{exe} -p {filename} ".format(**locals()), |
| 3940 |
returncodes = [0]) |
| 3941 |
self.rm_testdir() |
| 3942 |
@unittest.expectedFailure |
| 3943 |
def test_65773(self): |
| 3944 |
""" unzzip-mix -l $(CVE).zip """ |
| 3945 |
tmpdir = self.testdir() |
| 3946 |
filename = self.zip_CVE_2019_70 |
| 3947 |
file_url = self.url_CVE_2019_70 |
| 3948 |
if not download_raw(file_url, filename, tmpdir): |
| 3949 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3950 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3951 |
exe = self.bins("unzzip-mix") |
| 3952 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3953 |
returncodes = [0]) |
| 3954 |
# |
| 3955 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3956 |
returncodes = [0,2]) |
| 3957 |
# self.assertLess(len(run.output), 30) |
| 3958 |
self.assertEqual(os.path.getsize(tmpdir+"/POC1"), 135) |
| 3959 |
self.assertEqual(os.path.getsize(tmpdir+"/POC2"), 135) |
| 3960 |
self.assertEqual(os.path.getsize(tmpdir+"/POC3"), 303) |
| 3961 |
self.rm_testdir() |
| 3962 |
def test_65774(self): |
| 3963 |
""" unzzip-zap -l $(CVE).zip """ |
| 3964 |
tmpdir = self.testdir() |
| 3965 |
filename = self.zip_CVE_2019_70 |
| 3966 |
file_url = self.url_CVE_2019_70 |
| 3967 |
if not download_raw(file_url, filename, tmpdir): |
| 3968 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3969 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3970 |
exe = self.bins("unzzip") |
| 3971 |
run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()), |
| 3972 |
returncodes = [0]) |
| 3973 |
# |
| 3974 |
run = shell("cd {tmpdir} && ../{exe} {filename} ".format(**locals()), |
| 3975 |
returncodes = [0]) |
| 3976 |
self.assertEqual(os.path.getsize(tmpdir+"/POC1"), 135) |
| 3977 |
self.assertEqual(os.path.getsize(tmpdir+"/POC2"), 135) |
| 3978 |
self.assertEqual(os.path.getsize(tmpdir+"/POC3"), 303) |
| 3979 |
self.rm_testdir() |
| 3980 |
def test_65779(self): |
| 3981 |
""" check $(CVE).zip """ |
| 3982 |
tmpdir = self.testdir() |
| 3983 |
filename = self.zip_CVE_2019_70 |
| 3984 |
file_url = self.url_CVE_2019_70 |
| 3985 |
if not download_raw(file_url, filename, tmpdir): |
| 3986 |
self.skipTest("no zip_CVE_2019_70 available: " + filename) |
| 3987 |
if not os.path.isfile(os.path.join(tmpdir, filename)): self.skipTest("missing " + filename) |
| 3988 |
shell("ls -l {tmpdir}/{filename}".format(**locals())) |
| 3989 |
size = os.path.getsize(os.path.join(tmpdir, filename)) |
| 3990 |
self.assertEqual(size, 771) |
| 3991 |
|
| 3992 |
|
| 3993 |
def test_91000_zzshowme_check_sfx(self): |
| 3994 |
""" create an *.exe that can extract its own zip content """ |
| 3995 |
mkzip=self.bins("mkzip") |
| 3996 |
exefile = "tmp.zzshowme" + exeext |
| 3997 |
libstub1 = ".libs/zzipself" + exeext |
| 3998 |
libstub2 = "zzipself" + exeext |
| 3999 |
libstub = os.path.exists(libstub1) and libstub1 or libstub2 |
| 4000 |
txtfile_name = readme |
| 4001 |
txtfile = self.src(readme) |
| 4002 |
# add the extract-stub so we have reserved the size |
| 4003 |
run = shell("{mkzip} -0 -j {exefile}.zip {libstub}".format(**locals())) |
| 4004 |
self.assertFalse(run.returncode) |
| 4005 |
# add the actual content which may now be compressed |
| 4006 |
run = shell("{mkzip} -9 -j {exefile}.zip {txtfile}".format(**locals())) |
| 4007 |
self.assertFalse(run.returncode) |
| 4008 |
# rename .zip to .exe and put the extract-stub at the start |
| 4009 |
shutil.copy(exefile+".zip", exefile) |
| 4010 |
setstub="./zzipsetstub" + exeext |
| 4011 |
run = shell("{setstub} {exefile} {libstub}".format(**locals())) |
| 4012 |
self.assertFalse(run.returncode) |
| 4013 |
os.chmod(exefile, 0o755) |
| 4014 |
# now ask the new .exe to show some of its own content |
| 4015 |
run = shell("./{exefile} {txtfile_name}".format(**locals())) |
| 4016 |
self.assertFalse(run.returncode) |
| 4017 |
txt = open(txtfile).read() |
| 4018 |
self.assertEqual(txt.split("\n"), run.output.split("\n")) |
| 4019 |
|
| 4020 |
def test_99000_make_test1w_zip(self): |
| 4021 |
""" create a test1w.zip using zzip/write functions. """ |
| 4022 |
exe=self.bins("zzip") |
| 4023 |
run = shell("{exe} --version".format(**locals())) |
| 4024 |
if "- NO -" in run.output: |
| 4025 |
self.skipTest("- NO -D_ZZIP_ENABLE_WRITE") |
| 4026 |
return |
| 4027 |
zipfile=self.testzip() |
| 4028 |
tmpdir=self.testdir() |
| 4029 |
exe=self.bins("zzip") |
| 4030 |
for i in [1,2,3,4,5,6,7,8,9]: |
| 4031 |
filename = os.path.join(tmpdir,"file.%i" % i) |
| 4032 |
filetext = "file-%i\n" % i |
| 4033 |
self.mkfile(filename, filetext) |
| 4034 |
filename = os.path.join(tmpdir,"README") |
| 4035 |
filetext = self.readme() |
| 4036 |
self.mkfile(filename, filetext) |
| 4037 |
self.rm_zipfile() |
| 4038 |
shell("../{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir) |
| 4039 |
self.assertGreater(os.path.getsize(zipfile), 10) |
| 4040 |
|
| 4041 |
|
| 4042 |
|
| 4043 |
|
| 4044 |
if __name__ == "__main__": |
| 4045 |
import optparse |
| 4046 |
_o = optparse.OptionParser("%prog [options] test_xxx") |
| 4047 |
_o.add_option("-D", "--downloadonly", action="store_true", default=downloadonly, |
| 4048 |
help="setup helper: get downloads only [%default]") |
| 4049 |
_o.add_option("-d", "--downloaddir", metavar="DIR", default=downloaddir, |
| 4050 |
help="put and get downloads from here [%default]") |
| 4051 |
_o.add_option("-n", "--nodownloads", action="store_true", default=nodownloads, |
| 4052 |
help="no downloads / skipping CVE zip file tests [%default]") |
| 4053 |
_o.add_option("--downloads", metavar="YES", default="") |
| 4054 |
_o.add_option("-b", "--bindir", metavar="DIR", default=bindir, |
| 4055 |
help="path to the bindir to use [%default]") |
| 4056 |
_o.add_option("-s", "--topsrcdir", metavar="DIR", default=topsrcdir, |
| 4057 |
help="path to the top srcdir / unpack directory [%default]") |
| 4058 |
_o.add_option("-t", "--testdatadir", metavar="DIR", default=testdatadir, |
| 4059 |
help="path where temporary testdata is created [%default]") |
| 4060 |
_o.add_option("-Z", "--mkzip", metavar="EXE", default=mkzip, |
| 4061 |
help="name or path to zip.exe for *.zip creation [%default]") |
| 4062 |
_o.add_option("-U", "--unzip", metavar="EXE", default=unzip, |
| 4063 |
help="name or path to unzip.exe to unpack *.zip [%default]") |
| 4064 |
_o.add_option("-E", "--exeext", metavar="EXT", default=exeext, |
| 4065 |
help="the executable extension (automake $(EXEEXT)) [%default]") |
| 4066 |
_o.add_option("--xmlresults", metavar="FILE", default=None, |
| 4067 |
help="capture results as a junit xml file [%default]") |
| 4068 |
_o.add_option("-v", "--verbose", action="count", default=0, |
| 4069 |
help="increase logging output [%default]") |
| 4070 |
opt, args = _o.parse_args() |
| 4071 |
logging.basicConfig(level = logging.WARNING - 10 * opt.verbose) |
| 4072 |
downloadonly = opt.downloadonly |
| 4073 |
downloaddir = opt.downloaddir |
| 4074 |
nodownloads = yesno(opt.nodownloads) |
| 4075 |
if opt.downloads: |
| 4076 |
nodownloads = not yesno(opt.downloads) |
| 4077 |
topsrcdir = opt.topsrcdir |
| 4078 |
bindir = opt.bindir |
| 4079 |
testdatdir = opt.testdatadir |
| 4080 |
if opt.mkzip.endswith("-NOTFOUND"): |
| 4081 |
logg.error(" no infozip 'zip' found, expect failing tests (given -Z %s)", opt.mkzip) |
| 4082 |
else: |
| 4083 |
mkzip = opt.mkzip |
| 4084 |
if opt.unzip.endswith("-NOTFOUND") or len(opt.unzip) < 3: |
| 4085 |
logg.error("no infozip 'unzip' found, expect skipped tests (given -U %s)", opt.unzip) |
| 4086 |
unzip_skip = True |
| 4087 |
else: |
| 4088 |
unzip = opt.unzip |
| 4089 |
exeext = opt.exeext |
| 4090 |
# |
| 4091 |
if downloadonly: |
| 4092 |
downloads = 0 |
| 4093 |
for classname in sorted(list(globals())): |
| 4094 |
if not classname.endswith("Test"): |
| 4095 |
continue |
| 4096 |
testclass = globals()[classname] |
| 4097 |
for item in sorted(dir(testclass)): |
| 4098 |
if item.startswith("url_"): |
| 4099 |
name = item.replace("url_", "zip_") |
| 4100 |
if name in testclass.__dict__: |
| 4101 |
url = testclass.__dict__[item] |
| 4102 |
zip = testclass.__dict__[name] |
| 4103 |
download(url, zip) |
| 4104 |
downloads += 1 |
| 4105 |
if downloads: |
| 4106 |
sys.exit(0) |
| 4107 |
logg.error("could not download any file") |
| 4108 |
sys.exit(1) |
| 4109 |
# |
| 4110 |
if not args: args += [ "test_" ] |
| 4111 |
suite = unittest.TestSuite() |
| 4112 |
for arg in args: |
| 4113 |
for classname in sorted(list(globals())): |
| 4114 |
if not classname.endswith("Test"): |
| 4115 |
continue |
| 4116 |
testclass = globals()[classname] |
| 4117 |
for method in sorted(dir(testclass)): |
| 4118 |
if "*" not in arg: arg += "*" |
| 4119 |
if arg.startswith("_"): arg = arg[1:] |
| 4120 |
if matches(method, arg): |
| 4121 |
suite.addTest(testclass(method)) |
| 4122 |
|
| 4123 |
xmlresults = opt.xmlresults |
| 4124 |
if xmlresults: |
| 4125 |
try: import xmlrunner |
| 4126 |
except: xmlresults=None |
| 4127 |
if xmlresults: |
| 4128 |
if os.path.exists(opt.xmlresults): |
| 4129 |
os.remove(opt.xmlresults) |
| 4130 |
logg.info("xml results into %s", opt.xmlresults) |
| 4131 |
Runner = xmlrunner.XMLTestRunner |
| 4132 |
result = Runner(output=opt.xmlresults).run(suite) |
| 4133 |
else: |
| 4134 |
Runner = unittest.TextTestRunner |
| 4135 |
result = Runner(verbosity=opt.verbose).run(suite) |
| 4136 |
if not result.wasSuccessful(): |
| 4137 |
sys.exit(1) |