From c3673aaa5b65e8670c218bdfb5916a4112b628c7 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Wed, 14 Jan 2026 13:29:34 +0100 Subject: [PATCH] [core,tcp] Don't ignore connect errors Backport of commit 0bdd8da0993231216a7bb4d5e6e33e47d817a944. Co-Authored-By: Claude --- libfreerdp/core/tcp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 1d7eda92e..8a731f117 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -26,8 +26,11 @@ #include #include +#include + #include #include +#include #include #if !defined(_WIN32) @@ -846,12 +849,19 @@ static BOOL freerdp_tcp_connect_timeout(rdpContext* context, int sockfd, struct if (WAIT_OBJECT_0 != status) goto fail; - status = recv(sockfd, NULL, 0, 0); - - if (status == SOCKET_ERROR) { - if (WSAGetLastError() == WSAECONNRESET) + INT32 optval = 0; + socklen_t optlen = sizeof(optval); + if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, &optlen) < 0) + goto fail; + + if (optval != 0) + { + char ebuffer[256] = { 0 }; + WLog_DBG(TAG, "connect failed with error: %s [%" PRId32 "]", + winpr_strerror(optval, ebuffer, sizeof(ebuffer)), optval); goto fail; + } } status = WSAEventSelect(sockfd, handles[0], 0); -- 2.52.0