Skip to content

Commit b741121

Browse files
committed
Fixes #5262
1 parent a11f79e commit b741121

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.6.12.5"
23+
VERSION = "1.6.12.6"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/api.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import sqlite3
1818
import sys
1919
import tempfile
20+
import threading
2021
import time
2122

2223
from lib.core.common import dataToStdout
@@ -88,6 +89,7 @@ def __init__(self, database=None):
8889
def connect(self, who="server"):
8990
self.connection = sqlite3.connect(self.database, timeout=3, isolation_level=None, check_same_thread=False)
9091
self.cursor = self.connection.cursor()
92+
self.lock = threading.Lock()
9193
logger.debug("REST-JSON API %s connected to IPC database" % who)
9294

9395
def disconnect(self):
@@ -101,17 +103,20 @@ def commit(self):
101103
self.connection.commit()
102104

103105
def execute(self, statement, arguments=None):
104-
while True:
105-
try:
106-
if arguments:
107-
self.cursor.execute(statement, arguments)
106+
with self.lock:
107+
while True:
108+
try:
109+
if arguments:
110+
self.cursor.execute(statement, arguments)
111+
else:
112+
self.cursor.execute(statement)
113+
except sqlite3.OperationalError as ex:
114+
if "locked" not in getSafeExString(ex):
115+
raise
116+
else:
117+
time.sleep(1)
108118
else:
109-
self.cursor.execute(statement)
110-
except sqlite3.OperationalError as ex:
111-
if "locked" not in getSafeExString(ex):
112-
raise
113-
else:
114-
break
119+
break
115120

116121
if statement.lstrip().upper().startswith("SELECT"):
117122
return self.cursor.fetchall()

0 commit comments

Comments
 (0)