Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

SSDP suffers from multibyte string decode problem #149

Closed
alanmimms opened this issue Oct 2, 2017 · 3 comments
Closed

SSDP suffers from multibyte string decode problem #149

alanmimms opened this issue Oct 2, 2017 · 3 comments

Comments

@alanmimms
Copy link

It seems there are several other problems with multibyte string decoding and encoding in this package. Let me add my $0.0000000000002 😃.

Some device in my network has an SSDP response that blows up ssdp.py discovery sock.recv().decode("utf-8") with UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 5: invalid start byte. Since I cannot control all devices and since this is really a robustness issue, I tried replacing the bad UTF-8 with the default replacement by changing the code to

                    response = sock.recv(1024).decode("utf-8", "replace")

This solves my problem by allowing the discovery to continue even after a response from such an evil device is found. It seems harmless to do this.

@nielstron
Copy link
Contributor

Does the current policy of just excepting a UnicodeDecodeError and ignoring the whole device solve your problem too?

@alanmimms
Copy link
Author

Sorry I have no information on "current policy" since my solution worked for me and I have been using it. Did someone change code to implement the policy you mention? If so I could probably update and answer your question.

@nielstron
Copy link
Contributor

Yes, currently any decode error are just excepted and the whole string discarded. If your solution works though, maybe someone else will emerge with a similar problem.

@balloob balloob closed this as completed May 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants