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

Skip to content

Commit 63d7cd6

Browse files
committed
Minor patch (for late threading issues)
1 parent d886b08 commit 63d7cd6

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.revision import getRevisionNumber
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.0.5.34"
22+
VERSION = "1.0.5.35"
2323
REVISION = getRevisionNumber()
2424
STABLE = VERSION.count('.') <= 2
2525
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")
@@ -130,6 +130,9 @@
130130
# Default timeout for running commands over backdoor
131131
BACKDOOR_RUN_CMD_TIMEOUT = 5
132132

133+
# Number of seconds to wait for thread finalization at program end
134+
THREAD_FINALIZATION_TIMEOUT = 1
135+
133136
# Maximum number of techniques used in inject.py/getValue() per one value
134137
MAX_TECHNIQUES_PER_VALUE = 2
135138

sqlmap.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from lib.core.profiling import profile
5555
from lib.core.settings import IS_WIN
5656
from lib.core.settings import LEGAL_DISCLAIMER
57+
from lib.core.settings import THREAD_FINALIZATION_TIMEOUT
5758
from lib.core.settings import VERSION
5859
from lib.core.testing import smokeTest
5960
from lib.core.testing import liveTest
@@ -276,15 +277,16 @@ def main():
276277
if conf.get("dumper"):
277278
conf.dumper.flush()
278279

279-
if threading.activeCount() > 1:
280-
logger.debug("short delay for thread finalization")
281-
try:
282-
time.sleep(0.5)
283-
except KeyboardInterrupt:
284-
pass
280+
# short delay for thread finalization
281+
try:
282+
_ = time.time()
283+
while threading.activeCount() > 1 and (time.time() - _) > THREAD_FINALIZATION_TIMEOUT:
284+
time.sleep(0.01)
285+
except KeyboardInterrupt:
286+
pass
285287

286288
# Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program
287-
if conf.get("threads", 0) > 1 or conf.get("dnsServer"):
289+
if threading.activeCount() > 1:
288290
os._exit(0)
289291

290292
if __name__ == "__main__":

0 commit comments

Comments
 (0)