Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect returns caused by improper address filter in socket.getfqdn #100374

Closed
MTAwsl opened this issue Dec 20, 2022 · 0 comments
Closed

Incorrect returns caused by improper address filter in socket.getfqdn #100374

MTAwsl opened this issue Dec 20, 2022 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@MTAwsl
Copy link
Contributor

MTAwsl commented Dec 20, 2022

Bug report

When getfqdn called with name "::", instead of returning gethostname(), it will call gethostbyaddr("::").
This will raise an exception "socket.herror: [Errno 1] Unknown host", which will cause a 30 seconds(timeout) delay and return incorrect result. (Tested only on macOS Ventura 13.0.0.1, Python 3.10.6)
The solution is to add a filter to the first if statement, in line 792 socket.py, which will be included in my further pull-request.

import socket
socket.getfqdn("::") # This will block 30 seconds and returns "::" instead of hostname

Your environment

  • CPython versions tested on: Python 3.10.6 (main, Aug 11 2022, 13:36:31) [Clang 13.1.6 (clang-1316.0.21.2.5)] on Darwin
  • Operating system and architecture: macOS Ventura 13.0.0.1, arm64

Linked PRs

@MTAwsl MTAwsl added the type-bug An unexpected behavior, bug, or error label Dec 20, 2022
MTAwsl added a commit to MTAwsl/cpython that referenced this issue Dec 21, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 21, 2022
(cherry picked from commit 12be23cf3c1301be2c6b8fd4cb2cd35a567d2ea2)

Co-authored-by: Dominic Socular <BBH@awsl.rip>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 21, 2022
(cherry picked from commit 12be23cf3c1301be2c6b8fd4cb2cd35a567d2ea2)

Co-authored-by: Dominic Socular <BBH@awsl.rip>
miss-islington added a commit that referenced this issue Dec 21, 2022
(cherry picked from commit 12be23c)

Co-authored-by: Dominic Socular <BBH@awsl.rip>
miss-islington added a commit that referenced this issue Dec 21, 2022
(cherry picked from commit 12be23c)

Co-authored-by: Dominic Socular <BBH@awsl.rip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants