diff --git a/paramiko/message.py b/paramiko/message.py index 1a5151c..bcdfdba 100644 --- a/paramiko/message.py +++ b/paramiko/message.py @@ -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): diff --git a/paramiko/util.py b/paramiko/util.py index 8abdc0c..e5ab076 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -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