diff --git a/CHANGES b/CHANGES index 1742439..92995e6 100644 --- a/CHANGES +++ b/CHANGES @@ -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. diff --git a/xio-ip.c b/xio-ip.c index dcc8c45..a2ca953 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -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) {