From 4d87b0ff67e71be6a6ff031f13e2b5914288582f Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sat, 9 Feb 2019 23:18:08 +0100 Subject: [PATCH] Fixes #3467 and #3463 --- lib/core/datatype.py | 11 ++++------- lib/core/decorators.py | 15 ++++++++++----- lib/core/settings.py | 2 +- txt/checksum.md5 | 6 +++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/core/datatype.py b/lib/core/datatype.py index d32386f06..60407700e 100644 --- a/lib/core/datatype.py +++ b/lib/core/datatype.py @@ -120,15 +120,12 @@ class LRUDict(object): return key in self.cache def __getitem__(self, key): - try: - value = self.cache.pop(key) - self.cache[key] = value - return value - except KeyError: - return -1 + value = self.cache.pop(key) + self.cache[key] = value + return value def get(self, key): - return self.__getitem__(self, key) + return self.__getitem__(key) def __setitem__(self, key, value): try: diff --git a/lib/core/decorators.py b/lib/core/decorators.py index ecc29d58e..d8e3f8829 100644 --- a/lib/core/decorators.py +++ b/lib/core/decorators.py @@ -24,12 +24,17 @@ def cachedmethod(f, cache=LRUDict(capacity=MAX_CACHE_ITEMS)): @functools.wraps(f) def _(*args, **kwargs): - with _lock: - key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs))).hexdigest(), 16) & 0x7fffffffffffffff - if key not in cache: - cache[key] = f(*args, **kwargs) + key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs))).hexdigest(), 16) & 0x7fffffffffffffff - return cache[key] + try: + result = cache[key] + except KeyError: + result = f(*args, **kwargs) + + with _lock: + cache[key] = result + + return result return _ diff --git a/lib/core/settings.py b/lib/core/settings.py index 6ac48a8c1..7f9baef50 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import OS # sqlmap version (...) -VERSION = "1.3.2.14" +VERSION = "1.3.2.15" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/txt/checksum.md5 b/txt/checksum.md5 index 367313dc4..c053bed0e 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -33,8 +33,8 @@ a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py 964885db1ac028fa622ee5ba20f061b1 lib/core/common.py de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py -e1f7758f433202c50426efde5eb96768 lib/core/datatype.py -1646402a733e564f05025e848b323cf9 lib/core/decorators.py +00828c4455321b6987e3f882f4ef4f92 lib/core/datatype.py +3ec93893ad8b1e060540753b7f8a8caf lib/core/decorators.py 5f4680b769ae07f22157bd832c97cf8f lib/core/defaults.py 9dfc69ba47209a4ceca494dde9ee8183 lib/core/dicts.py 4ba141124699fd7a763dea82f17fe523 lib/core/dump.py @@ -50,7 +50,7 @@ d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py 7d8a22c582ad201f65b73225e4456170 lib/core/replication.py 3179d34f371e0295dd4604568fb30bcd lib/core/revision.py d6269c55789f78cf707e09a0f5b45443 lib/core/session.py -8aa51078439218dacde3c4283ed22845 lib/core/settings.py +75098335768c0cfa062995a83ceaef78 lib/core/settings.py 4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py 10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py 43772ea73e9e3d446f782af591cb4eda lib/core/target.py