Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntenore Gatta (tmow) <antenore@simbiosi.org>2022-04-06 13:32:51 +0300
committerAntenore Gatta (tmow) <antenore@simbiosi.org>2022-04-06 13:32:51 +0300
commit45adf13a7a209fa96fbff20871d8c539ccf7c354 (patch)
treea948032c5cca78640415616355de6cb544daf4fe
parent67781f0ae343c4fed3b6295095a2ca5453b30548 (diff)
parentb54a3e52ce49f7ae5dcf8cb9db1900408e72d378 (diff)
Merge branch 'issue_2666' into 'master'
Add mutex to protect RDP clipboard->srv_data. Fixes #2666 Closes #2666 See merge request Remmina/Remmina!2395
-rw-r--r--plugins/rdp/rdp_cliprdr.c30
-rw-r--r--plugins/rdp/rdp_plugin.h1
2 files changed, 20 insertions, 11 deletions
diff --git a/plugins/rdp/rdp_cliprdr.c b/plugins/rdp/rdp_cliprdr.c
index ad7695fc1..17fb5f33b 100644
--- a/plugins/rdp/rdp_cliprdr.c
+++ b/plugins/rdp/rdp_cliprdr.c
@@ -224,17 +224,17 @@ void remmina_rdp_cliprdr_cached_clipboard_free(rfClipboard *clipboard)
TRACE_CALL(__func__);
guint fmt;
-
- if (clipboard->srv_data == NULL)
- return;
-
- fmt = clipboard->format;
- if (fmt == CB_FORMAT_PNG || fmt == CF_DIB || fmt == CF_DIBV5 || fmt == CB_FORMAT_JPEG) {
- g_object_unref(clipboard->srv_data);
- } else {
- free(clipboard->srv_data);
+ pthread_mutex_lock(&clipboard->srv_data_mutex);
+ if (clipboard->srv_data != NULL) {
+ fmt = clipboard->format;
+ if (fmt == CB_FORMAT_PNG || fmt == CF_DIB || fmt == CF_DIBV5 || fmt == CB_FORMAT_JPEG) {
+ g_object_unref(clipboard->srv_data);
+ } else {
+ free(clipboard->srv_data);
+ }
+ clipboard->srv_data = NULL;
}
- clipboard->srv_data = NULL;
+ pthread_mutex_unlock(&clipboard->srv_data_mutex);
}
@@ -362,8 +362,10 @@ static UINT remmina_rdp_cliprdr_server_format_list(CliprdrClientContext *context
REMMINA_PLUGIN_DEBUG("gp=%p adding a dummy text target (empty text) for local clipboard, because we have no interesting targets from the server. Putting it in the local clipboard cache.");
GdkAtom atom = gdk_atom_intern("UTF8_STRING", TRUE);
gtk_target_list_add(list, atom, 0, CF_UNICODETEXT);
+ pthread_mutex_lock(&clipboard->srv_data_mutex);
clipboard->srv_data = malloc(1);
((char *)(clipboard->srv_data))[0] = 0;
+ pthread_mutex_unlock(&clipboard->srv_data_mutex);
clipboard->format = CF_UNICODETEXT;
}
@@ -555,7 +557,10 @@ static UINT remmina_rdp_cliprdr_server_format_data_response(CliprdrClientContext
}
}
+ pthread_mutex_lock(&clipboard->srv_data_mutex);
clipboard->srv_data = output;
+ pthread_mutex_unlock(&clipboard->srv_data_mutex);
+
if (output != NULL)
REMMINA_PLUGIN_DEBUG("gp=%p: clipboard local cache data has been loaded", gp);
else
@@ -663,11 +668,11 @@ void remmina_rdp_cliprdr_request_data(GtkClipboard *gtkClipboard, GtkSelectionDa
g_warning("[RDP] gp=%p internal error: pthread_cond_timedwait() returned %d\n", gp, rc);
}
}
-
pthread_mutex_unlock(&clipboard->transfer_clip_mutex);
}
+ pthread_mutex_lock(&clipboard->srv_data_mutex);
if (clipboard->srv_data != NULL) {
REMMINA_PLUGIN_DEBUG("gp=%p pasting data to local application", gp);
/* We have data in cache, just paste it */
@@ -685,6 +690,7 @@ void remmina_rdp_cliprdr_request_data(GtkClipboard *gtkClipboard, GtkSelectionDa
} else {
REMMINA_PLUGIN_DEBUG("gp=%p cannot paste data to local application because ->srv_data is NULL", gp);
}
+ pthread_mutex_unlock(&clipboard->srv_data_mutex);
}
@@ -958,6 +964,8 @@ void remmina_rdp_cliprdr_init(rfContext *rfi, CliprdrClientContext *cliprdr)
pthread_cond_init(&clipboard->transfer_clip_cond, NULL);
clipboard->srv_clip_data_wait = SCDW_NONE;
+ pthread_mutex_init(&clipboard->srv_data_mutex, NULL);
+
cliprdr->MonitorReady = remmina_rdp_cliprdr_monitor_ready;
cliprdr->ServerCapabilities = remmina_rdp_cliprdr_server_capabilities;
cliprdr->ServerFormatList = remmina_rdp_cliprdr_server_format_list;
diff --git a/plugins/rdp/rdp_plugin.h b/plugins/rdp/rdp_plugin.h
index 0ac987ef5..a9cf47e85 100644
--- a/plugins/rdp/rdp_plugin.h
+++ b/plugins/rdp/rdp_plugin.h
@@ -139,6 +139,7 @@ struct rf_clipboard {
pthread_cond_t transfer_clip_cond;
enum { SCDW_NONE, SCDW_BUSY_WAIT, SCDW_ABORTING } srv_clip_data_wait;
gpointer srv_data;
+ pthread_mutex_t srv_data_mutex;
UINT32 server_html_format_id;