aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Ivanov <[email protected]>2019-02-21 23:37:46 +0700
committerVitaly Ivanov <[email protected]>2019-02-21 23:37:46 +0700
commit004c3664b1431bf648bbdd9840107e4c00553b56 (patch)
tree34c518a5c3c9f264c424b3ce23333164df54ad7c
parentfcef7bd5f78721d83a5ca0f0ec522dd04e446d6a (diff)
macOS fix for tls_server in UDP/DTLS mode
-rw-r--r--src/cli/tls_server.cpp5
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");
}