changeset 93156:3ef12fa772f2

* dbusbind.c (xd_read_message): Removed extra copying of message strings. Check for NULL `interface' or `member'.
author Michael Albinus <michael.albinus@gmx.de>
date Sun, 23 Mar 2008 16:45:39 +0000
parents 09cc3d0d41ce
children 8c4ca251cdb6
files src/dbusbind.c
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/dbusbind.c	Sun Mar 23 11:44:23 2008 +0000
+++ b/src/dbusbind.c	Sun Mar 23 16:45:39 2008 +0000
@@ -165,7 +165,7 @@
    : DBUS_TYPE_INVALID)
 
 /* Return a list pointer which does not have a Lisp symbol as car.  */
-#define XD_NEXT_VALUE(object)					\
+#define XD_NEXT_VALUE(object)						\
   ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object)
 
 /* Compute SIGNATURE of OBJECT.  It must have a form that it can be
@@ -1140,10 +1140,7 @@
   DBusMessageIter iter;
   unsigned int dtype;
   int mtype;
-  char uname[DBUS_MAXIMUM_NAME_LENGTH];
-  char path[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; /* Unlimited in D-Bus spec.  */
-  char interface[DBUS_MAXIMUM_NAME_LENGTH];
-  char member[DBUS_MAXIMUM_NAME_LENGTH];
+  const char *uname, *path, *interface, *member;
 
   /* Open a connection to the bus.  */
   connection = xd_initialize (bus);
@@ -1175,11 +1172,15 @@
 
   /* Read message type, unique name, object path, interface and member
      from the message.  */
-  mtype =            dbus_message_get_type (dmessage);
-  strcpy (uname,     dbus_message_get_sender (dmessage));
-  strcpy (path,      dbus_message_get_path (dmessage));
-  strcpy (interface, dbus_message_get_interface (dmessage));
-  strcpy (member,    dbus_message_get_member (dmessage));
+  mtype     = dbus_message_get_type (dmessage);
+  uname     = dbus_message_get_sender (dmessage);
+  path      = dbus_message_get_path (dmessage);
+  interface = dbus_message_get_interface (dmessage);
+  member    = dbus_message_get_member (dmessage);
+
+  /* dbus-registered-functions-table requires non nil interface and member. */
+  if ((NULL == interface) || (NULL == member))
+    goto cleanup;
 
   XD_DEBUG_MESSAGE ("Event received: %d %s %s %s %s %s",
 		    mtype, uname, path, interface, member,
@@ -1210,11 +1211,8 @@
 			     args);
 
 	  /* Add uname, path, interface and member to the event.  */
-	  event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
-			     event.arg);
-	  event.arg = Fcons ((interface == NULL
-			      ? Qnil : build_string (interface)),
-			     event.arg);
+	  event.arg = Fcons (build_string (member), event.arg);
+	  event.arg = Fcons (build_string (interface), event.arg);
 	  event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
 			     event.arg);
 	  event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)),
@@ -1235,7 +1233,7 @@
      value = CDR_SAFE (value);
     }
 
-  /* Cleanup.  */
+ cleanup:
   dbus_message_unref (dmessage);
   RETURN_UNGCPRO (Qnil);
 }