From fdad787681d06ea37c452dea02c0b7b8a72e519c Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 7 Apr 2014 20:22:51 +0200 Subject: [PATCH] Graceful abort in case of an invalid option in configuration file --- lib/parse/configfile.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/parse/configfile.py b/lib/parse/configfile.py index d9e98bf1f..3715a3c97 100644 --- a/lib/parse/configfile.py +++ b/lib/parse/configfile.py @@ -31,12 +31,17 @@ def configFileProxy(section, option, boolean=False, integer=False): global config if config.has_option(section, option): - if boolean: - value = config.getboolean(section, option) if config.get(section, option) else False - elif integer: - value = config.getint(section, option) if config.get(section, option) else 0 - else: - value = config.get(section, option) + try: + if boolean: + value = config.getboolean(section, option) if config.get(section, option) else False + elif integer: + value = config.getint(section, option) if config.get(section, option) else 0 + else: + value = config.get(section, option) + except ValueError, ex: + errMsg = "error occurred while processing the option " + errMsg += "'%s' in provided configuration file ('%s')" % (option, str(ex)) + raise SqlmapSyntaxException(errMsg) if value: conf[option] = value