File xrdp-fix-segfaults-in-xrdp-chansrv-code.patch of Package xrdp.2184
Index: xrdp-0.6.1/sesman/chansrv/clipboard.c
===================================================================
--- xrdp-0.6.1.orig/sesman/chansrv/clipboard.c
+++ xrdp-0.6.1/sesman/chansrv/clipboard.c
@@ -873,25 +873,31 @@ clipboard_event_selection_notify(XEvent*
{
LOG(5, ("clipboard_event_selection_notify: UTF8_STRING data_size %d",
data_size));
- g_free(g_last_clip_data);
- g_last_clip_size = data_size;
- g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
- g_last_clip_type = g_utf8_atom;
- g_memcpy(g_last_clip_data, data, g_last_clip_size);
- g_last_clip_data[g_last_clip_size] = 0;
- send_format_announce = 1;
+ if ((data) && (data_size > 0))
+ {
+ g_free(g_last_clip_data);
+ g_last_clip_size = data_size;
+ g_last_clip_data = (char *) g_malloc(g_last_clip_size + 1, 0);
+ g_last_clip_type = g_utf8_atom;
+ g_memcpy(g_last_clip_data, data, g_last_clip_size);
+ g_last_clip_data[g_last_clip_size] = 0;
+ send_format_announce = 1;
+ }
}
else if (lxevent->target == XA_STRING)
{
LOG(5, ("clipboard_event_selection_notify: XA_STRING data_size %d",
data_size));
- g_free(g_last_clip_data);
- g_last_clip_size = data_size;
- g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
- g_last_clip_type = XA_STRING;
- g_memcpy(g_last_clip_data, data, g_last_clip_size);
- g_last_clip_data[g_last_clip_size] = 0;
- send_format_announce = 1;
+ if ((data) && (data_size > 0))
+ {
+ g_free(g_last_clip_data);
+ g_last_clip_size = data_size;
+ g_last_clip_data = (char *) g_malloc(g_last_clip_size + 1, 0);
+ g_last_clip_type = XA_STRING;
+ g_memcpy(g_last_clip_data, data, g_last_clip_size);
+ g_last_clip_data[g_last_clip_size] = 0;
+ send_format_announce = 1;
+ }
}
else
{
Index: xrdp-0.6.1/sesman/chansrv/chansrv.c
===================================================================
--- xrdp-0.6.1.orig/sesman/chansrv/chansrv.c
+++ xrdp-0.6.1/sesman/chansrv/chansrv.c
@@ -647,14 +647,19 @@ main(int argc, char** argv)
g_signal_terminate(term_signal_handler); /* SIGTERM */
g_signal_user_interrupt(term_signal_handler); /* SIGINT */
g_signal_pipe(nil_signal_handler); /* SIGPIPE */
+
display_text = g_getenv("DISPLAY");
LOG(1, ("main: DISPLAY env var set to %s", display_text));
- get_display_num_from_display(display_text);
+
+ if (display_text)
+ get_display_num_from_display(display_text);
+
if (g_display_num == 0)
{
LOG(0, ("main: error, display is zero"));
return 1;
}
+
LOG(1, ("main: using DISPLAY %d", g_display_num));
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
g_term_event = g_create_wait_obj(text);