Set protocol in init_client()
authorTodd Short <todd.short@me.com>
Tue, 8 Mar 2022 14:36:43 +0000 (09:36 -0500)
committerTodd Short <todd.short@me.com>
Thu, 10 Mar 2022 14:24:48 +0000 (09:24 -0500)
If TCP is being used, protocol = 0 is passed to init_client(), then
protocol == IPPROTO_TCP fails when attempting to set BIO_SOCK_NODELAY.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17838)

apps/lib/s_socket.c

index 0751d460e8c71b7527f45e3cb5cfd0ede1191171..e5802d50547f09c5ddd9e1e75ae7c2a39f149ede 100644 (file)
@@ -162,7 +162,7 @@ int init_client(int *sock, const char *host, const char *port,
 #endif
 
         if (!BIO_connect(*sock, BIO_ADDRINFO_address(ai),
-                         protocol == IPPROTO_TCP ? BIO_SOCK_NODELAY : 0)) {
+                         BIO_ADDRINFO_protocol(ai) == IPPROTO_TCP ? BIO_SOCK_NODELAY : 0)) {
             BIO_closesocket(*sock);
             *sock = INVALID_SOCKET;
             continue;