about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2017-07-21 18:59:33 +0200
committerAjax <commial@gmail.com>2017-07-21 18:59:33 +0200
commitd1d3fdf6904b800f2864a3c364054ad4ff841463 (patch)
tree10df015ae407821b0a544c9c2839992ad4b6bba3
parent4dfca940e75ad8af65b69dd9bab9ff503141984b (diff)
downloadmiasm-d1d3fdf6904b800f2864a3c364054ad4ff841463.tar.gz
miasm-d1d3fdf6904b800f2864a3c364054ad4ff841463.zip
Aarch64: mask ROR/ROL result to avoid overflow
Diffstat (limited to '')
-rw-r--r--miasm2/arch/aarch64/arch.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/miasm2/arch/aarch64/arch.py b/miasm2/arch/aarch64/arch.py
index 7c8f22ef..fc481698 100644
--- a/miasm2/arch/aarch64/arch.py
+++ b/miasm2/arch/aarch64/arch.py
@@ -1066,11 +1066,13 @@ class aarch64_gpreg_sftimm(reg_noarg, m_arg):
 
 
 def ror(value, amount, size):
-    return (value >> amount) | (value << (size - amount))
+    mask = (1 << size) - 1
+    return ((value >> amount) | (value << (size - amount))) & mask
 
 
 def rol(value, amount, size):
-    return (value << amount) | (value >> (size - amount))
+    mask = (1 << size) - 1
+    return ((value << amount) | (value >> (size - amount)) & mask)
 
 UINTS = {32: uint32, 64: uint64}