diff options
author | Vitaly Ivanov <[email protected]> | 2019-02-21 23:37:46 +0700 |
---|---|---|
committer | Vitaly Ivanov <[email protected]> | 2019-02-21 23:37:46 +0700 |
commit | 004c3664b1431bf648bbdd9840107e4c00553b56 (patch) | |
tree | 34c518a5c3c9f264c424b3ce23333164df54ad7c | |
parent | fcef7bd5f78721d83a5ca0f0ec522dd04e446d6a (diff) |
macOS fix for tls_server in UDP/DTLS mode
-rw-r--r-- | src/cli/tls_server.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index 9ec4ff7aa..8954889cf 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -111,7 +111,10 @@ class TLS_Server final : public Command, public Botan::TLS::Callbacks struct sockaddr_in from; socklen_t from_len = sizeof(sockaddr_in); - if(::recvfrom(server_fd, nullptr, 0, MSG_PEEK, reinterpret_cast<struct sockaddr*>(&from), &from_len) != 0) + // macOS handles zero size buffers differently - it will return 0 even if there's no incoming data, + // and after that connect() will fail as sockaddr_in from is not initialized + int dummy; + if(::recvfrom(server_fd, &dummy, sizeof(dummy), MSG_PEEK, reinterpret_cast<struct sockaddr*>(&from), &from_len) != 0) { throw CLI_Error("Could not peek next packet"); } |