From 9535ec8fd31b18e9f865b82bc54893516e877db4 Mon Sep 17 00:00:00 2001 From: Mark Mossberg Date: Thu, 9 Nov 2017 11:28:24 -0500 Subject: [PATCH] Fix all integral type checks that forget long (#555) --- manticore/core/smtlib/expression.py | 6 +++--- manticore/core/smtlib/operators.py | 4 ++-- manticore/utils/log.py | 2 +- scripts/stats.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manticore/core/smtlib/expression.py b/manticore/core/smtlib/expression.py index 9aba1b1..43adbf9 100644 --- a/manticore/core/smtlib/expression.py +++ b/manticore/core/smtlib/expression.py @@ -530,7 +530,7 @@ class UnsignedGreaterOrEqual(BoolOperation): class Array(Expression): def __init__(self, index_bits, index_max, *operands, **kwargs): assert index_bits in (32, 64, 256) - assert index_max is None or isinstance(index_max, int) + assert index_max is None or isinstance(index_max, (int, long)) assert index_max is None or index_max > 0 and index_max < 2 ** index_bits self._index_bits = index_bits self._index_max = index_max @@ -699,7 +699,7 @@ class ArraySelect(BitVec, Operation): class BitVecSignExtend(BitVecOperation): def __init__(self, operand, size_dest, *args, **kwargs): assert isinstance(operand, BitVec) - assert isinstance(size_dest, int) + assert isinstance(size_dest, (int, long)) assert size_dest >= operand.size super(BitVecSignExtend, self).__init__(size_dest, operand, *args, **kwargs) self.extend = size_dest - operand.size @@ -726,7 +726,7 @@ class BitVecExtract(BitVecOperation): class BitVecConcat(BitVecOperation): def __init__(self, size_dest, *operands, **kwargs): - assert isinstance(size_dest, int) + assert isinstance(size_dest, (int, long)) assert all(map(lambda x: isinstance(x, BitVec), operands)) assert size_dest == sum(map(lambda x: x.size, operands)) super(BitVecConcat, self).__init__(size_dest, *operands, **kwargs) diff --git a/manticore/core/smtlib/operators.py b/manticore/core/smtlib/operators.py index e9855f7..68401c2 100644 --- a/manticore/core/smtlib/operators.py +++ b/manticore/core/smtlib/operators.py @@ -9,7 +9,7 @@ def ORD(s): return s else: return BitVecExtract(s, 0, 7) - elif isinstance(s, int): + elif isinstance(s, (int, long)): return s & 0xff else: return ord(s) @@ -254,7 +254,7 @@ def simplify(value): def SAR(size, a, b): - assert isinstance(size, int) + assert isinstance(size, (int, long)) if isinstance(b, BitVec) and b.size != size: b = ZEXTEND(b, size) if isinstance(a, BitVec): diff --git a/manticore/utils/log.py b/manticore/utils/log.py index a221599..d74af1e 100644 --- a/manticore/utils/log.py +++ b/manticore/utils/log.py @@ -16,7 +16,7 @@ class ContextFilter(logging.Filter): return '{}.{}'.format(prefix, components[-1]) def filter(self, record): - if hasattr(self, 'stateid') and isinstance(self.stateid, int): + if hasattr(self, 'stateid') and isinstance(self.stateid, (int, long)): record.stateid = '[%d]' % self.stateid else: record.stateid = '' diff --git a/scripts/stats.py b/scripts/stats.py index 6da1934..954fdd9 100644 --- a/scripts/stats.py +++ b/scripts/stats.py @@ -72,7 +72,7 @@ elif args.bbs: break def p(x): - return isinstance(x, int) and hex(x) or x + return isinstance(x, (int, long)) and hex(x) or x print '%s -> [%s]'%(p(origin), ', '.join(map(p, targets)) )