summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@twitter.com>2009-04-14 18:15:57 -0700
committerRobey Pointer <robey@twitter.com>2009-04-14 18:15:57 -0700
commit7bd95eb0d0f126087b3ae59654b2154d82476045 (patch)
tree5be04437b8bd05d3d7f2af3474cebf935c3692fd
parent74b581c170bdf177eac2a1c5e1f6480b2eee24bf (diff)
patch from james bardin: bail early if the high byte is zero.
-rw-r--r--paramiko/message.py2
-rw-r--r--paramiko/util.py2
2 files changed, 3 insertions, 1 deletions
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