Skip to content

Commit e570858

Browse files
committed
Implementation for an Issue sqlmapproject#183
1 parent a64438f commit e570858

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/request/basic.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import re
1212
import StringIO
13+
import struct
1314
import zlib
1415

1516
from lib.core.common import extractErrorMessage
@@ -27,6 +28,7 @@
2728
from lib.core.exception import sqlmapCompressionException
2829
from lib.core.htmlentities import htmlEntities
2930
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
31+
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
3032
from lib.core.settings import ML
3133
from lib.core.settings import META_CHARSET_REGEX
3234
from lib.core.settings import PARSE_HEADERS_LIMIT
@@ -182,12 +184,17 @@ def decodePage(page, contentEncoding, contentType):
182184
return getUnicode(page)
183185

184186
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
187+
if not kb.pageCompress:
188+
return None
189+
185190
try:
186191
if contentEncoding.lower() == "deflate":
187-
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
188-
data = StringIO.StringIO(zlib.decompress(page, -15))
192+
data = StringIO.StringIO(zlib.decompress(page, -15)) # Reference: http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
189193
else:
190194
data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page))
195+
size = struct.unpack("<l", page[-4:])[0] # Reference: http://pydoc.org/get.cgi/usr/local/lib/python2.5/gzip.py
196+
if size > MAX_CONNECTION_TOTAL_SIZE:
197+
raise Exception, "size too large"
191198

192199
page = data.read()
193200
except Exception, msg:

0 commit comments

Comments
 (0)