From c1f829d1314221a10af7686b6b7a834db8560533 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 8 Sep 2015 11:15:31 +0200 Subject: [PATCH] Removing last remnants of bad handling the exceptions as strings --- lib/controller/checks.py | 8 ++++---- lib/request/httpshandler.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index f4c053ec9..6f266702f 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1278,8 +1278,8 @@ def checkNullConnection(): infoMsg = "NULL connection is supported with 'skip-read' method" logger.info(infoMsg) - except SqlmapConnectionException, errMsg: - errMsg = getUnicode(errMsg) + except SqlmapConnectionException, ex: + errMsg = getUnicode(ex.message) raise SqlmapConnectionException(errMsg) finally: @@ -1326,7 +1326,7 @@ def checkConnection(suppressOutput=False): else: kb.errorIsNone = True - except SqlmapConnectionException, errMsg: + except SqlmapConnectionException, ex: if conf.ipv6: warnMsg = "check connection to a provided " warnMsg += "IPv6 address with a tool like ping6 " @@ -1336,7 +1336,7 @@ def checkConnection(suppressOutput=False): singleTimeWarnMessage(warnMsg) if any(code in kb.httpErrorCodes for code in (httplib.NOT_FOUND, )): - errMsg = getUnicode(errMsg) + errMsg = getUnicode(ex.message) logger.critical(errMsg) if conf.multipleTargets: diff --git a/lib/request/httpshandler.py b/lib/request/httpshandler.py index 6906f4686..08e6b4193 100644 --- a/lib/request/httpshandler.py +++ b/lib/request/httpshandler.py @@ -55,9 +55,9 @@ class HTTPSConnection(httplib.HTTPSConnection): break else: sock.close() - except (ssl.SSLError, socket.error, httplib.BadStatusLine), errMsg: + except (ssl.SSLError, socket.error, httplib.BadStatusLine), ex: self._tunnel_host = None - logger.debug("SSL connection error occurred ('%s')" % errMsg) + logger.debug("SSL connection error occurred ('%s')" % ex.message) # Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext # https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni @@ -75,9 +75,9 @@ class HTTPSConnection(httplib.HTTPSConnection): break else: sock.close() - except (ssl.SSLError, socket.error, httplib.BadStatusLine), errMsg: + except (ssl.SSLError, socket.error, httplib.BadStatusLine), ex: self._tunnel_host = None - logger.debug("SSL connection error occurred ('%s')" % errMsg) + logger.debug("SSL connection error occurred ('%s')" % ex.message) if not success: raise SqlmapConnectionException("can't establish SSL connection")