[mutter] xprops: Null-terminate property reply values
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] xprops: Null-terminate property reply values
- Date: Tue, 12 Jan 2016 15:53:36 +0000 (UTC)
commit a7a376ae1fafb7c9da50d9fe51fc08b0ec13f55e
Author: Sebastian Keller <sebastian-keller gmx de>
Date: Sun Jan 10 04:15:09 2016 +0100
xprops: Null-terminate property reply values
Some of the mutter code using these properties expects them to be
null-terminated whereas xcb does not use null-terminated strings:
http://xcb.freedesktop.org/XcbRationale/
This was in some cases resulting in the WM_CLASS property containing
garbage data which broke application matching, caused the hot-corner and
window-switcher to stop working, or was exposed as text in the UI.
https://bugzilla.gnome.org/show_bug.cgi?id=759658
src/x11/xprops.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/x11/xprops.c b/src/x11/xprops.c
index be38824..e3bd931 100644
--- a/src/x11/xprops.c
+++ b/src/x11/xprops.c
@@ -194,6 +194,7 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
{
xcb_get_property_reply_t *reply;
xcb_generic_error_t *error;
+ int length;
reply = xcb_get_property_reply (xcb_conn, cookie, &error);
if (error)
@@ -209,8 +210,15 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
results->prop = NULL;
if (results->type != None)
- results->prop = g_memdup (xcb_get_property_value (reply),
- xcb_get_property_value_length (reply));
+ {
+ length = xcb_get_property_value_length (reply);
+ /* Leave room for a trailing '\0' since xcb doesn't return null-terminated
+ * strings
+ */
+ results->prop = g_malloc (length + 1);
+ memcpy (results->prop, xcb_get_property_value (reply), length);
+ results->prop[length] = '\0';
+ }
free (reply);
return (results->prop != NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]