patch from james bardin: bail early if the high byte is zero.

This commit is contained in:
Robey Pointer 2009-04-14 18:15:57 -07:00
parent 74b581c170
commit 7bd95eb0d0
2 changed files with 3 additions and 1 deletions

View File

@ -111,7 +111,7 @@ class Message (object):
"""
b = self.packet.read(n)
if len(b) < n:
return '\x00'*n
return b + '\x00' * (n - len(b))
return b
def get_byte(self):

View File

@ -135,6 +135,8 @@ def safe_string(s):
def bit_length(n):
norm = deflate_long(n, 0)
hbyte = ord(norm[0])
if hbyte == 0:
return 1
bitlen = len(norm) * 8
while not (hbyte & 0x80):
hbyte <<= 1