Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73968a4

Browse files
committed
Minor update
1 parent e129a30 commit 73968a4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/request/redirecthandler.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from lib.core.enums import REDIRECTION
2020
from lib.core.exception import SqlmapConnectionException
2121
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
22+
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
2223
from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS
2324
from lib.core.settings import MAX_TOTAL_REDIRECTIONS
2425
from lib.core.threads import getCurrentThreadData
@@ -49,11 +50,18 @@ def http_error_302(self, req, fp, code, msg, headers):
4950
redurl = self._get_header_redirect(headers)
5051

5152
try:
52-
content = fp.read()
53+
content = fp.read(MAX_CONNECTION_TOTAL_SIZE)
5354
except Exception, msg:
5455
dbgMsg = "there was a problem while retrieving "
5556
dbgMsg += "redirect response content (%s)" % msg
5657
logger.debug(dbgMsg)
58+
finally:
59+
if content:
60+
try: # try to write it back to the read buffer so we could reuse it in further steps
61+
fp.fp._rbuf.truncate(0)
62+
fp.fp._rbuf.write(content)
63+
except:
64+
pass
5765

5866
content = decodePage(content, headers.get(HTTPHEADER.CONTENT_ENCODING), headers.get(HTTPHEADER.CONTENT_TYPE))
5967

0 commit comments

Comments
 (0)