aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-02-22 11:01:33 -0500
committerJack Lloyd <[email protected]>2019-02-22 11:01:33 -0500
commit0986b99ea81cd1c67b444e387db8f8daccc5a534 (patch)
tree9e9bdb48d7df0616fef24ad52858ceaaf529bcf6
parentfcef7bd5f78721d83a5ca0f0ec522dd04e446d6a (diff)
parent56bbc543e290893cffbd783b501091afe7ac1b59 (diff)
Merge GH #1840 Fix tls_server in DTLS mode on OSX
-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..ad300e8d4 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, reinterpret_cast<char*>(&dummy), sizeof(dummy), MSG_PEEK, reinterpret_cast<struct sockaddr*>(&from), &from_len) != 0)
{
throw CLI_Error("Could not peek next packet");
}