3 ms·
Depending on the language/library that might not always be possible. For instance python's zip library only provides an extract function, without a way to hook
by gruez 2y ago
Depending on the language/library that might not always be possible. For instance python's zip library only provides an extract function, without a way to hook into the decompression process, or limit how much can be written out. Sure, you can probably fork the library to add in the checks yourself, but from a maintainability perspective it might be less work to do with the partition solution.
- banana_giraffe 2y agoIt also provides an open function for the files in a zip file. I see no reason something like this won't bail after a small limit: import zipfile with zipfile.ZipFile("zipbomb.zip") as zip: for name in zip.namelist(): print("working on " + name) left = 1000000 with open("dest_" + name, "wb") as fdest, zip.open(name) as fsrc: while True: block = fsrc.read(1000) if len(block) == 0: break fdest.write(block) left -= len(block) if left <= 0: print("too much data!") break