From bb4ac41ff70398083bffbab50f827494c71b8d1d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 12 Dec 2014 04:40:44 +0100 Subject: [PATCH] Patch for an Issue #1016 --- lib/core/common.py | 4 ++-- lib/core/target.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index c045b05f1..b9aeb7a0e 100755 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -2849,13 +2849,13 @@ def showHttpErrorCodes(): msg += "could mean that some kind of protection is involved (e.g. WAF)" logger.warn(msg) -def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="replace"): +def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="replace", buffering=1): """ Returns file handle of a given filename """ try: - return codecs.open(filename, mode, encoding, errors) + return codecs.open(filename, mode, encoding, errors, buffering) except IOError: errMsg = "there has been a file opening error for filename '%s'. " % filename errMsg += "Please check %s permissions on a file " % ("write" if \ diff --git a/lib/core/target.py b/lib/core/target.py index 29a0c4665..774d97619 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -18,6 +18,7 @@ from lib.core.common import getUnicode from lib.core.common import hashDBRetrieve from lib.core.common import intersect from lib.core.common import normalizeUnicode +from lib.core.common import openFile from lib.core.common import paramToDict from lib.core.common import readInput from lib.core.common import resetCookieJar @@ -497,7 +498,7 @@ def _setResultsFile(): if not conf.resultsFP: conf.resultsFilename = os.path.join(paths.SQLMAP_OUTPUT_PATH, time.strftime(RESULTS_FILE_FORMAT).lower()) - conf.resultsFP = codecs.open(conf.resultsFilename, "w+", UNICODE_ENCODING, buffering=0) + conf.resultsFP = openFile(conf.resultsFilename, "w+", UNICODE_ENCODING, buffering=0) conf.resultsFP.writelines("Target URL,Place,Parameter,Techniques%s" % os.linesep) logger.info("using '%s' as the CSV results file in multiple targets mode" % conf.resultsFilename)