]> git.ipfire.org Git - thirdparty/git.git/commit
daemon: fix IPv6 address corruption in lookup_hostname()
authorSebastien Tardif <sebtardif@ncf.ca>
Wed, 27 May 2026 18:18:29 +0000 (18:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2026 20:28:37 +0000 (05:28 +0900)
commit4a1c74e2dad0d3a1f112c381fc279bbd7ea163a7
tree1ff3da5dad8aaef9af732c9e28bdda6ffa779d66
parent67ad42147a7acc2af6074753ebd03d904476118f
daemon: fix IPv6 address corruption in lookup_hostname()

getaddrinfo() is called with AF_UNSPEC hints, so it may return IPv6
results. However, the code unconditionally casts ai_addr to
sockaddr_in and passes AF_INET to inet_ntop(). On IPv6-only hosts,
this reads from the wrong struct offset, producing garbage IP
addresses.

Fix this by checking ai_family and extracting the address pointer
into a local variable before calling inet_ntop() once with the
correct family. Die on unexpected address families.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
daemon.c