From 838e02ab4287b40c6ea043abcd5a0065ef9554c8 Mon Sep 17 00:00:00 2001 From: Anselm Kruis Date: Fri, 20 Mar 2015 11:52:23 +0100 Subject: According to RFC 4254 sec 6.5 the "command" string of an "exec" channel request is a byte-string. Previously paramiko assumed "command" to be UTF-8 encoded. Invalid UTF-8 sequences caused an UnicodeDecodeError. This commit changes a test case to uses a non UTF-8 string and fixes the bug. --- paramiko/channel.py | 2 +- tests/test_transport.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paramiko/channel.py b/paramiko/channel.py index 23323650..0acd85ef 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -989,7 +989,7 @@ class Channel (object): else: ok = server.check_channel_env_request(self, name, value) elif key == 'exec': - cmd = m.get_text() + cmd = m.get_string() if server is None: ok = False else: diff --git a/tests/test_transport.py b/tests/test_transport.py index 485a18e8..fb83fd2f 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -246,7 +246,7 @@ class TransportTest(ParamikoTest): chan = self.tc.open_session() schan = self.ts.accept(1.0) try: - chan.exec_command('no') + chan.exec_command(b'command contains \xfc and is not a valid UTF-8 string') self.assertTrue(False) except SSHException: pass -- cgit v1.2.3