Repository navigation
getaddrinfo invalid port number #74896
Description
Activity
Some getaddrinfo implementations do not detect invalid numeric services and blindly pass the port number to htons(). For example, service "960179" is returned as port 42675.
glibc
https://sourceware.org/bugzilla/show_bug.cgi?id=16208
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/posix/getaddrinfo.c;h=a8bdd9a1829409bd797637b2c4fca4d67a11012d;hb=HEAD#l435
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/posix/getaddrinfo.c;h=a8bdd9a1829409bd797637b2c4fca4d67a11012d;hb=HEAD#l2313AIX 7.1 libc
BrokenModules/getaddrinfo
https://github.com/python/cpython/blob/master/Modules/getaddrinfo.c#L342On the other hand, for example, OpenBSD and musl check the port range
https://github.com/openbsd/src/blob/master/lib/libc/asr/getaddrinfo_async.c#L477
https://git.musl-libc.org/cgit/musl/tree/src/network/lookup_serv.c#n53Modules/getaddrinfo should be fixed.
The configure script should detect whether the system getaddrinfo is broken. If so, a wrapper that checks numeric services, and returns EAI_SERVICE or calls the system getaddrinfo should be used in place of the system getaddrinfo.
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.7 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorextension-modulesC modules in the Modules dirC modules in the Modules dirand removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jun 20, 2017 See also bpo-30710.
See also bpo-30786.
- addedtopic-socketRelated to the socket, socketserver and selectors modulesRelated to the socket, socketserver and selectors modules
on Jul 3, 2026
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: