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

Skip to content

Commit 3a256d7

Browse files
authored
Fix BitVec with symbolic offset and fix TranslatorSmtlib.unique thread safety (trailofbits#1792)
* minor fixes * fix spacing * always put it through BitVecExtract
1 parent 0f904d5 commit 3a256d7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

manticore/core/smtlib/operators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def ULE(a, b):
124124

125125

126126
def EXTRACT(x, offset, size):
127-
if isinstance(x, BitVec):
127+
if isinstance(x, BitVec) and isinstance(offset, BitVec):
128+
return BitVecExtract(x >> offset, 0, size)
129+
elif isinstance(x, BitVec):
128130
if offset == 0 and size == x.size:
129131
return x
130132
return BitVecExtract(x, offset, size)

manticore/core/smtlib/visitors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import operator
88
import math
9+
import threading
910
from decimal import Decimal
1011

1112
logger = logging.getLogger(__name__)
@@ -859,6 +860,7 @@ class TranslatorSmtlib(Translator):
859860
"""
860861

861862
unique = 0
863+
unique_lock = threading.Lock()
862864

863865
def __init__(self, use_bindings=False, *args, **kw):
864866
assert "bindings" not in kw
@@ -874,7 +876,8 @@ def _add_binding(self, expression, smtlib):
874876
if smtlib in self._bindings_cache:
875877
return self._bindings_cache[smtlib]
876878

877-
TranslatorSmtlib.unique += 1
879+
with TranslatorSmtlib.unique_lock:
880+
TranslatorSmtlib.unique += 1
878881
name = "a_%d" % TranslatorSmtlib.unique
879882

880883
self._bindings.append((name, expression, smtlib))

0 commit comments

Comments
 (0)