about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2017-05-10 00:33:50 +0200
committerGitHub <noreply@github.com>2017-05-10 00:33:50 +0200
commitf76c4aadc06141caf1bbd775a258928d73794a35 (patch)
tree9f02bd94636002fdb2704dcd42cc439429dd0646
parentb2918d46721d79cac0b15eeacece7477c7835f56 (diff)
parent5364019f8aa8544947768345696c248e6053e2c3 (diff)
downloadmiasm-f76c4aadc06141caf1bbd775a258928d73794a35.tar.gz
miasm-f76c4aadc06141caf1bbd775a258928d73794a35.zip
Merge pull request #554 from commial/sanitize/force-assignblk-dest
Sanitize/force assignblk dest
-rw-r--r--miasm2/ir/ir.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py
index e5f0c8db..8154d4da 100644
--- a/miasm2/ir/ir.py
+++ b/miasm2/ir/ir.py
@@ -33,7 +33,13 @@ class AssignBlock(object):
     EAX = EBX
     EBX = EAX
 
-    Also provides common manipulation on this assignments
+    -> Exchange between EBX and EAX
+
+    AssignBlock can be seen as a dictionnary where keys are the destinations
+    (ExprId or ExprMem), and values their corresponding sources.
+
+    Also provides common manipulation on this assignments.
+
     """
     __slots__ = ["_assigns", "_instr"]
 
@@ -124,6 +130,10 @@ class AssignBlock(object):
             args = [expr for (expr, _, _) in args]
             new_src = m2_expr.ExprCompose(*args)
 
+        # Sanity check
+        if not isinstance(new_dst, (m2_expr.ExprId, m2_expr.ExprMem)):
+            raise TypeError("Destination cannot be a %s" % type(new_dst))
+
         self._assigns[new_dst] = new_src
 
     def __setitem__(self, dst, src):