1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-12 12:36:51 +00:00

Use correct IPPROTO with CONNECT

This commit is contained in:
Gerhard 2025-02-17 20:30:26 +01:00
parent 186a323c2d
commit 48f3341d82
2 changed files with 13 additions and 0 deletions

View file

@ -87,6 +87,9 @@ Corrections:
Fixed preprocessor directives in macro invocation.
Thanks to Mario de Weerd for reporting this issue.
CONNECT addresses could use a wrong IPPROTO when getaddrinfo() does not
support the selected one (at least on Debian-4 with SCTP).
Features:
POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T,
makes it possible to terminate Socat in case the queue is empty.

View file

@ -459,6 +459,7 @@ int _xiogetaddrinfo(const char *node, const char *service,
#else /* HAVE_PROTOTYPE_LIB_getipnodebyname || nothing */
struct hostent *host;
#endif
bool restore_proto = false;
int error_num;
Debug8("_xiogetaddrinfo(node=\"%s\", service=\"%s\", family=%d, socktype=%d, protoco=%d, ai_flags={0x%04x/0x%04x} }, res=%p",
@ -585,6 +586,7 @@ int _xiogetaddrinfo(const char *node, const char *service,
return EAI_SERVICE;
}
/* Probably unsupported protocol (e.g. UDP-Lite), fallback to 0 */
restore_proto = true;
hints.ai_protocol = 0;
continue;
}
@ -613,6 +615,14 @@ int _xiogetaddrinfo(const char *node, const char *service,
#endif /* WITH_MSGLEVEL <= E_DEBUG */
}
if (restore_proto) {
struct addrinfo *record = *res;
while (record) {
record->ai_protocol = protocol;
record = record->ai_next;
}
}
#elif HAVE_PROTOTYPE_LIB_getipnodebyname /* !HAVE_GETADDRINFO */
if (node != NULL) {