[tor-commits] [trunnel/master] Repair integer encoding :(

nickm at torproject.org nickm at torproject.org
Fri Dec 30 04:13:10 UTC 2016


commit 6d7892932e01fa35b091d08961d7a7c1baab7407
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Dec 29 23:13:06 2016 -0500

    Repair integer encoding :(
---
 lib/trunnel/SeedFuzzer.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/trunnel/SeedFuzzer.py b/lib/trunnel/SeedFuzzer.py
index 369eb88..9726c3a 100644
--- a/lib/trunnel/SeedFuzzer.py
+++ b/lib/trunnel/SeedFuzzer.py
@@ -193,8 +193,12 @@ class NamedInt(object):
             # didn't.  How about 3? 3 is a nice number.
             val = 3
         # encode val little-endian in width bytes.
-        return b"".join(chr((val >> (self._width-i)) & 0xff)
-                        for i in xrange(1, self._width+1))
+        return encodeInt(val, self._width)
+
+
+def encodeInt(val, width):
+    return b"".join(chr((val >> (width-i)*8) & 0xff)
+                    for i in xrange(1, width+1))
 
 
 def findLength(lst):



More information about the tor-commits mailing list