From 6abeb53e69193966329df3beeae857051cd329b6 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sat, 22 Jan 2022 18:54:33 +0000 Subject: [PATCH] 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. --- src/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core.c b/src/core.c index 18591ac..3dbf624 100644 --- a/src/core.c +++ b/src/core.c @@ -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