Handle the case when received data is in wrong encoding (not utf-8).

This commit is contained in:
Andris Raugulis committed 2016-10-18 09:45:03 +03:00
1 parent 6b76e68d0d
commit 8ca6ec591d
2 files changed
+16 -1

No files matched your search

+4 -1
View File
@@ -1657,7 +1657,10 @@ def audit(conf, sshv=None):
if err is None:
packet_type, payload = s.read_packet(sshv)
if packet_type < 0:
payload = payload.decode('utf-8') if payload else u'empty'
try:
payload = payload.decode('utf-8') if payload else u'empty'
except UnicodeDecodeError:
payload = u'"{0}"'.format(repr(payload).lstrip('b')[1:-1])
if payload == u'Protocol major versions differ.':
if sshv == 2 and conf.ssh1:
audit(conf, 1)