Skip to content

Commit

Permalink
GUACAMOLE-1140: Fix RDP pipe svc race condition with lock and null ch…
Browse files Browse the repository at this point in the history
…eck.
  • Loading branch information
necouchman committed Dec 28, 2023
1 parent f0ab665 commit 2363681
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/protocols/rdp/channels/pipe-svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ void guac_rdp_pipe_svc_send_pipes(

guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;

guac_common_list_lock(rdp_client->available_svc);
if (rdp_client->available_svc != NULL) {
guac_common_list_lock(rdp_client->available_svc);

/* Send pipe for each allocated SVC's output stream */
guac_common_list_element* current = rdp_client->available_svc->head;
while (current != NULL) {
guac_rdp_pipe_svc_send_pipe(socket, (guac_rdp_pipe_svc*) current->data);
current = current->next;
}

/* Send pipe for each allocated SVC's output stream */
guac_common_list_element* current = rdp_client->available_svc->head;
while (current != NULL) {
guac_rdp_pipe_svc_send_pipe(socket, (guac_rdp_pipe_svc*) current->data);
current = current->next;
guac_common_list_unlock(rdp_client->available_svc);
}

guac_common_list_unlock(rdp_client->available_svc);
}

void guac_rdp_pipe_svc_add(guac_client* client, guac_rdp_pipe_svc* pipe_svc) {
Expand Down
4 changes: 4 additions & 0 deletions src/protocols/rdp/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ static int guac_rdp_join_pending_handler(guac_client* client) {
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
guac_socket* broadcast_socket = client->pending_socket;

pthread_rwlock_rdlock(&(rdp_client->lock));

/* Synchronize any audio stream for each pending user */
if (rdp_client->audio)
guac_client_foreach_pending_user(
Expand All @@ -131,6 +133,8 @@ static int guac_rdp_join_pending_handler(guac_client* client) {
guac_socket_flush(broadcast_socket);
}

pthread_rwlock_unlock(&(rdp_client->lock));

return 0;

}
Expand Down

0 comments on commit 2363681

Please sign in to comment.