How to protect myself from a gzip or bzip2 bomb?
This is related to the question about zip bombs , but having gzip or bzip2 compression in mind, e.g. a web service accepting .tar.gz files. Python provides a handy tarfile module that is convenient to use, but does not seem to provide protection against zipbombs. In python code using the tarfile module, what would be the most elegant way to detect zip bombs, preferably without duplicating too much logic (e.g. the transparent decompression support) from the tarfile module? And, just to make it a bit less simple: No real files are involved; the input is a file-like object (provided by the web