impacket
impacket copied to clipboard
bug fix issue #1675
This PR fixes issue reported on #1675. The patch decodes bytes returned from getData()
by default sys.stdout
encoding. The root cause of the bug is drop Python2 supporting.
Hi, the proposed solution will break on certain scenarios:
-
self.getData()
can return a bytes object which may not be a valid unicode string for the selected encoding - Here's a specific example:
-
stdout.encoding => 'utf-8'
-
self.getData() => b'\xc3'
-
b'\xc3'.decode('utf-8')
throws an exception:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data
-
I think that a better approach would be to represent that buffer in an encoding agnostic way, maybe by using binascii.hexlify(self.getData())
Thanks for your review. I applied your suggestion. Please recheck <3