From bf1b62d3c7a5aa3e76f45bd376491257e1f6c23a Mon Sep 17 00:00:00 2001 From: pwgcz Date: Mon, 30 Mar 2026 14:47:17 +0200 Subject: [PATCH] GUACAMOLE-2221: fix RDP busy-loop on transport failure When an RDP connection hits a transport-level failure (for example, a certificate error), the inner event loop in rdp.c can spin at 100% CPU. This happens because rdp_guac_client_wait_for_events() does not check FreeRDP's error state, so it keeps returning success even after a transport failure has been recorded. As a result, the loop never observes the error and continues polling indefinitely. Fix: check freerdp_get_last_error() in rdp_guac_client_wait_for_events() and return -1 when an error is recorded. This satisfies the function's contract to report errors and ensures the loop exits promptly. --- src/protocols/rdp/rdp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index 1ef85bee8..e2524d63c 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -468,6 +468,10 @@ static int rdp_guac_client_wait_for_events(guac_client* client, } + /* Bail out if FreeRDP has recorded a connection error */ + if (freerdp_get_last_error(GUAC_RDP_CONTEXT(rdp_inst)) != FREERDP_ERROR_SUCCESS) + return -1; + /* Wait was successful */ return 1; @@ -625,8 +629,10 @@ static int guac_rdp_handle_connection(guac_client* client) { /* Handle any queued FreeRDP events (this may result in RDP messages * being sent), aborting later if FreeRDP event handling fails */ - if (!guac_rdp_handle_events(rdp_client)) + if (!guac_rdp_handle_events(rdp_client)) { wait_result = -1; + break; + } /* Test whether the RDP server is closing the connection */ #ifdef HAVE_DISCONNECT_CONTEXT