patch from james bardin: bail early if the high byte is zero.
This commit is contained in:
parent
74b581c170
commit
7bd95eb0d0
|
@ -111,7 +111,7 @@ class Message (object):
|
||||||
"""
|
"""
|
||||||
b = self.packet.read(n)
|
b = self.packet.read(n)
|
||||||
if len(b) < n:
|
if len(b) < n:
|
||||||
return '\x00'*n
|
return b + '\x00' * (n - len(b))
|
||||||
return b
|
return b
|
||||||
|
|
||||||
def get_byte(self):
|
def get_byte(self):
|
||||||
|
|
|
@ -135,6 +135,8 @@ def safe_string(s):
|
||||||
def bit_length(n):
|
def bit_length(n):
|
||||||
norm = deflate_long(n, 0)
|
norm = deflate_long(n, 0)
|
||||||
hbyte = ord(norm[0])
|
hbyte = ord(norm[0])
|
||||||
|
if hbyte == 0:
|
||||||
|
return 1
|
||||||
bitlen = len(norm) * 8
|
bitlen = len(norm) * 8
|
||||||
while not (hbyte & 0x80):
|
while not (hbyte & 0x80):
|
||||||
hbyte <<= 1
|
hbyte <<= 1
|
||||||
|
|
Loading…
Reference in New Issue