From 7bd95eb0d0f126087b3ae59654b2154d82476045 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 14 Apr 2009 18:15:57 -0700 Subject: patch from james bardin: bail early if the high byte is zero. --- paramiko/message.py | 2 +- paramiko/util.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/paramiko/message.py b/paramiko/message.py index 1a5151ce..bcdfdba4 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 8abdc0ce..e5ab0769 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 -- cgit v1.2.3