Incorrect returns caused by improper address filter in socket.getfqdn · Issue #100374 · python/cpython (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@MTAwsl

Description

@MTAwsl

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

Linked PRs