6MB LimitedGzip file helper to avoid gzip bombs

This commit is contained in:
shortcutme 2017-08-09 14:19:09 +02:00
parent 4f729aa98f
commit f451ce6c91
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -194,3 +194,11 @@ def socketBindMonkeyPatch(bind_ip, bind_port):
socket.bind_addr = (bind_ip, int(bind_port))
socket.create_connection_original = socket.create_connection
socket.create_connection = create_connection
def limitedGzipFile(*args, **kwargs):
import gzip
class LimitedGzipFile(gzip.GzipFile):
def read(self, size=-1):
return super(LimitedGzipFile, self).read(1024*1024*6)
return LimitedGzipFile(*args, **kwargs)