Skip to content

[3.7] bpo-31922: Do not connect UDP sockets when broadcast is allowed (GH-423)#13162

Merged
miss-islington merged 1 commit intopython:3.7from
miss-islington:backport-63deaa5-3.7
May 7, 2019
Merged

[3.7] bpo-31922: Do not connect UDP sockets when broadcast is allowed (GH-423)#13162
miss-islington merged 1 commit intopython:3.7from
miss-islington:backport-63deaa5-3.7

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented May 7, 2019

Moved from python/asyncioGH-493.

This PR fixes issue python/asyncioGH-480, as explained in this comment.

The _SelectorDatagramTransport.sendto method has to be modified so _sock.sendto is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets? EDIT ... so _sock.send is used only if _sock is connected.

It also protects socket.getsockname against OSError in _SelectorTransport. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting).

https://bugs.python.org/issue31922
(cherry picked from commit 63deaa5)

Co-authored-by: Vincent Michel vxgmichel@gmail.com

https://bugs.python.org/issue31922

…onGH-423)

*Moved from python/asyncioGH-493.*

This PR fixes issue python/asyncioGH-480, as explained in [this comment](https://github.com/python/asyncio/issues/480GH-issuecomment-278703828).

The `_SelectorDatagramTransport.sendto` method has to be modified ~~so `_sock.sendto` is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets?~~ *EDIT* ... so `_sock.send` is used only if `_sock` is connected.

It also protects `socket.getsockname` against `OSError` in `_SelectorTransport`. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting).

https://bugs.python.org/issue31922
(cherry picked from commit 63deaa5)

Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
@miss-islington
Copy link
Copy Markdown
Contributor Author

@vxgmichel: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 19ca5b5 into python:3.7 May 7, 2019
@miss-islington miss-islington deleted the backport-63deaa5-3.7 branch May 7, 2019 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants