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

Skip to content

Commit fdad787

Browse files
committed
Graceful abort in case of an invalid option in configuration file
1 parent e3ccf45 commit fdad787

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

lib/parse/configfile.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ def configFileProxy(section, option, boolean=False, integer=False):
3131
global config
3232

3333
if config.has_option(section, option):
34-
if boolean:
35-
value = config.getboolean(section, option) if config.get(section, option) else False
36-
elif integer:
37-
value = config.getint(section, option) if config.get(section, option) else 0
38-
else:
39-
value = config.get(section, option)
34+
try:
35+
if boolean:
36+
value = config.getboolean(section, option) if config.get(section, option) else False
37+
elif integer:
38+
value = config.getint(section, option) if config.get(section, option) else 0
39+
else:
40+
value = config.get(section, option)
41+
except ValueError, ex:
42+
errMsg = "error occurred while processing the option "
43+
errMsg += "'%s' in provided configuration file ('%s')" % (option, str(ex))
44+
raise SqlmapSyntaxException(errMsg)
4045

4146
if value:
4247
conf[option] = value

0 commit comments

Comments
 (0)