1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-19 23:28:43 +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. Fixed preprocessor directives in macro invocation.
Thanks to Mario de Weerd for reporting this issue. 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: Features:
POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T, POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T,
makes it possible to terminate Socat in case the queue is empty. 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 */ #else /* HAVE_PROTOTYPE_LIB_getipnodebyname || nothing */
struct hostent *host; struct hostent *host;
#endif #endif
bool restore_proto = false;
int error_num; int error_num;
Debug8("_xiogetaddrinfo(node=\"%s\", service=\"%s\", family=%d, socktype=%d, protoco=%d, ai_flags={0x%04x/0x%04x} }, res=%p", 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; return EAI_SERVICE;
} }
/* Probably unsupported protocol (e.g. UDP-Lite), fallback to 0 */ /* Probably unsupported protocol (e.g. UDP-Lite), fallback to 0 */
restore_proto = true;
hints.ai_protocol = 0; hints.ai_protocol = 0;
continue; continue;
} }
@ -613,6 +615,14 @@ int _xiogetaddrinfo(const char *node, const char *service,
#endif /* WITH_MSGLEVEL <= E_DEBUG */ #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 */ #elif HAVE_PROTOTYPE_LIB_getipnodebyname /* !HAVE_GETADDRINFO */
if (node != NULL) { if (node != NULL) {