about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2016-04-05 14:07:37 +0200
committerCamille Mougey <commial@gmail.com>2016-04-05 14:07:37 +0200
commit5db3ce6a4a1bba435fd39b9700feb7cb2256663b (patch)
tree1ea7a2dfb33118fd6d9703a32ecd8e55ea868603
parent4eceb2b2e723409b610533788c0b98ec23a9e204 (diff)
parentf4220a38bc8724a58e554947002cec7b68ef16cd (diff)
downloadmiasm-5db3ce6a4a1bba435fd39b9700feb7cb2256663b.tar.gz
miasm-5db3ce6a4a1bba435fd39b9700feb7cb2256663b.zip
Merge pull request #348 from a-vincent/fix_getbits
fix bin_stream.getbits()
-rw-r--r--miasm2/core/bin_stream.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/miasm2/core/bin_stream.py b/miasm2/core/bin_stream.py
index cfcdf8a5..67a67de8 100644
--- a/miasm2/core/bin_stream.py
+++ b/miasm2/core/bin_stream.py
@@ -15,7 +15,6 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-import math
 
 
 class bin_stream(object):
@@ -78,7 +77,9 @@ class bin_stream(object):
         # Get initial bytes
         if n > self.getlen() * 8:
             raise IOError('not enough bits %r %r' % (n, len(self.bin) * 8))
-        temp = self.getbytes(start / 8, int(math.ceil(n / 8.)))
+        byte_start = start / 8
+        byte_stop = (start + n + 7) / 8
+        temp = self.getbytes(byte_start, byte_stop - byte_start)
         if not temp:
             raise IOError('cannot get bytes')