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 retVal[line] = True
else: else:
retVal.append(line) retVal.append(line)
except (IOError, OSError), ex: except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, ex) errMsg += "to read the content of file '%s' ('%s')" % (filename, ex)
raise SqlmapSystemException(errMsg) 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 SqlmapMissingPrivileges
from lib.core.exception import SqlmapSilentQuitException from lib.core.exception import SqlmapSilentQuitException
from lib.core.exception import SqlmapSyntaxException from lib.core.exception import SqlmapSyntaxException
from lib.core.exception import SqlmapSystemException
from lib.core.exception import SqlmapUnsupportedDBMSException from lib.core.exception import SqlmapUnsupportedDBMSException
from lib.core.exception import SqlmapUserQuitException from lib.core.exception import SqlmapUserQuitException
from lib.core.log import FORMATTER from lib.core.log import FORMATTER
@ -361,9 +362,14 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
kb.targets.add((url, method, data, cookie, tuple(headers))) kb.targets.add((url, method, data, cookie, tuple(headers)))
addedTargetUrls.add(url) addedTargetUrls.add(url)
fp = openFile(reqFile, "rb") checkFile(reqFile)
try:
content = fp.read() 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: if conf.scope:
logger.info("using regular expression '%s' for filtering targets" % conf.scope) logger.info("using regular expression '%s' for filtering targets" % conf.scope)