proxy_getaddrinfo(): Fill in ai_socktype if requested

If the application specifies a protocol but not a socket type,
normally getaddrinfo will select a corresponding protocol.

Mimic this behavior in our implementation of the function as well.
We only care about the case we're actually able to proxify
(SOCK_STREAM / IPPROTO_TCP).

Fixes proxifying pssh.
This commit is contained in:
Vladimir Panteleev 2022-01-22 18:54:33 +00:00 committed by rofl0r
parent 70629aaf25
commit 6abeb53e69

View File

@ -1018,6 +1018,8 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
p->ai_socktype = hints->ai_socktype;
p->ai_flags = hints->ai_flags;
p->ai_protocol = hints->ai_protocol;
if(!p->ai_socktype && p->ai_protocol == IPPROTO_TCP)
p->ai_socktype = SOCK_STREAM;
} else {
#ifndef AI_V4MAPPED
#define AI_V4MAPPED 0