openssl s_server: don't use sendto() with connected UDP socket
authorMatthew Hodgson <matthew@matrix.org>
Wed, 21 Nov 2018 02:00:52 +0000 (02:00 +0000)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Wed, 21 Nov 2018 20:04:38 +0000 (21:04 +0100)
Fixes #7675

On macOS, if you call `connect()` on a UDP socket you cannot then
call `sendto()` with a destination, otherwise it fails with Err#56
('socket is already connected').

By calling `BIO_ctrl_set_connected()` on the wbio we can tell it
that the socket has been connected and make it call `send()` rather
than `sendto()`.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/7676)

apps/s_server.c

index ac7dca607ba471f7fc90c72b43acda28ecf265ed..15b4b430da762af4efc212596d21ea6bb9d4321c 100644 (file)
@@ -2754,6 +2754,8 @@ static int init_ssl_connection(SSL *con)
                     BIO_ADDR_free(client);
                     return 0;
                 }
+
+                (void)BIO_ctrl_set_connected(wbio, client);
                 BIO_ADDR_free(client);
                 dtlslisten = 0;
             } else {