Patch for an Issue #968

This commit is contained in:
Miroslav Stampar 2014-11-24 10:13:56 +01:00
parent 2284535267
commit 2f744139fc
2 changed files with 10 additions and 4 deletions

View File

@ -1930,7 +1930,7 @@ def getFileItems(filename, commentPrefix='#', unicode_=True, lowercase=False, un
retVal[line] = True
else:
retVal.append(line)
except (IOError, OSError), ex:
except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, ex)
raise SqlmapSystemException(errMsg)

View File

@ -90,6 +90,7 @@ from lib.core.exception import SqlmapMissingMandatoryOptionException
from lib.core.exception import SqlmapMissingPrivileges
from lib.core.exception import SqlmapSilentQuitException
from lib.core.exception import SqlmapSyntaxException
from lib.core.exception import SqlmapSystemException
from lib.core.exception import SqlmapUnsupportedDBMSException
from lib.core.exception import SqlmapUserQuitException
from lib.core.log import FORMATTER
@ -361,9 +362,14 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
kb.targets.add((url, method, data, cookie, tuple(headers)))
addedTargetUrls.add(url)
fp = openFile(reqFile, "rb")
content = fp.read()
checkFile(reqFile)
try:
with openFile(reqFile, "rb") as f:
content = f.read()
except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (reqFile, ex)
raise SqlmapSystemException(errMsg)
if conf.scope:
logger.info("using regular expression '%s' for filtering targets" % conf.scope)