dbus/dbus dbus-message.c,1.105,1.106 dbus-sysdeps.c,1.65,1.66

Havoc Pennington hp@pdx.freedesktop.org
Fri, 10 Oct 2003 23:20:30 -0700


Update of /cvs/dbus/dbus/dbus
In directory pdx:/tmp/cvs-serv19181/dbus

Modified Files:
	dbus-message.c dbus-sysdeps.c 
Log Message:
2003-10-11  Havoc Pennington  <hp@pobox.com>

	* dbus/dbus-message.c (_dbus_message_test): add more test
	coverage, but #if 0 for now since they uncover a bug 
	not fixed yet; I think in re_align_field_recurse()
	(re_align_field_recurse): add FIXME about broken assertion

	* dbus/dbus-sysdeps.c (_dbus_sysdeps_test): add more test coverage

	* bus/connection.c: share a couple code bits with expirelist.c

	* bus/expirelist.h, bus/expirelist.c: implement a generic
	expire-items-after-N-seconds facility, was going to share between
	expiring connections and replies, decided not to use for expiring
	connections for now.

	* bus/connection.c: add tracking of expected replies

	* COPYING: include AFL 2.0 (still need to change all the file headers)



Index: dbus-message.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- dbus-message.c	10 Oct 2003 02:42:20 -0000	1.105
+++ dbus-message.c	11 Oct 2003 06:20:28 -0000	1.106
@@ -489,6 +489,9 @@
     case DBUS_TYPE_NAMED:
     case DBUS_TYPE_ARRAY:
     case DBUS_TYPE_DICT:
+      /* FIXME This is no good; we have to handle undefined header fields
+       * also. SECURITY and spec compliance issue.
+       */
       _dbus_assert_not_reached ("no defined header fields may contain a named, array or dict value");
       break;
     case DBUS_TYPE_INVALID:
@@ -540,7 +543,7 @@
       /* this must succeed because it was allocated on function entry and
        * DBusString doesn't ever realloc smaller
        */
-    _dbus_string_insert_bytes (&message->header, pos, -delta, 0);
+      _dbus_string_insert_bytes (&message->header, pos, -delta, 0);
     }
 
   return FALSE;
@@ -729,7 +732,7 @@
 	      len = strlen (old_value);
 
 	      _dbus_string_init_const_len (&v, old_value,
-					  len + 1); /* include nul */
+                                           len + 1); /* include nul */
 	      if (!_dbus_marshal_set_string (&message->header,
 					     message->byte_order,
 					     offset, &v, len))
@@ -741,7 +744,7 @@
 	}
 
       dbus_free (old_value);
-
+      
       return TRUE;
 
     failed:
@@ -6553,12 +6556,16 @@
   _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
   _dbus_assert (dbus_message_is_method_call (message, "Foo.TestInterface",
                                              "TestMethod"));
+  _dbus_assert (strcmp (dbus_message_get_path (message),
+                        "/org/freedesktop/TestPath") == 0);
   _dbus_message_set_serial (message, 1234);
   /* string length including nul byte not a multiple of 4 */
-  dbus_message_set_sender (message, "org.foo.bar1");
+  if (!dbus_message_set_sender (message, "org.foo.bar1"))
+    _dbus_assert_not_reached ("out of memory");
   _dbus_assert (dbus_message_has_sender (message, "org.foo.bar1"));
   dbus_message_set_reply_serial (message, 5678);
-  dbus_message_set_sender (message, NULL);
+  if (!dbus_message_set_sender (message, NULL))
+    _dbus_assert_not_reached ("out of memory");
   _dbus_assert (!dbus_message_has_sender (message, "org.foo.bar1"));
   _dbus_assert (dbus_message_get_serial (message) == 1234);
   _dbus_assert (dbus_message_get_reply_serial (message) == 5678);
@@ -6569,6 +6576,58 @@
   _dbus_assert (dbus_message_get_no_reply (message) == TRUE);
   dbus_message_set_no_reply (message, FALSE);
   _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
+
+#if 0
+  /* Set/get some header fields */
+  
+  if (!dbus_message_set_path (message, "/foo"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_path (message),
+                        "/foo") == 0);
+
+  if (!dbus_message_set_interface (message, "org.Foo"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_interface (message),
+                        "org.Foo") == 0);
+  
+  if (!dbus_message_set_member (message, "Bar"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_member (message),
+                        "Bar") == 0);
+
+  /* Set/get them with longer values */
+  if (!dbus_message_set_path (message, "/foo/bar"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_path (message),
+                        "/foo/bar") == 0);
+
+  if (!dbus_message_set_interface (message, "org.Foo.Bar"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_interface (message),
+                        "org.Foo.Bar") == 0);
+  
+  if (!dbus_message_set_member (message, "BarFoo"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_member (message),
+                        "BarFoo") == 0);
+
+  /* Realloc shorter again */
+  
+  if (!dbus_message_set_path (message, "/foo"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_path (message),
+                        "/foo") == 0);
+
+  if (!dbus_message_set_interface (message, "org.Foo"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_interface (message),
+                        "org.Foo") == 0);
+  
+  if (!dbus_message_set_member (message, "Bar"))
+    _dbus_assert_not_reached ("out of memory");
+  _dbus_assert (strcmp (dbus_message_get_member (message),
+                        "Bar") == 0);
+#endif
   
   dbus_message_unref (message);
   

Index: dbus-sysdeps.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- dbus-sysdeps.c	30 Sep 2003 02:32:53 -0000	1.65
+++ dbus-sysdeps.c	11 Oct 2003 06:20:28 -0000	1.66
@@ -3381,6 +3381,24 @@
       exit (1);
     }
 
+  _dbus_string_init_const (&str, "0xff");
+  if (!_dbus_string_parse_double (&str,
+				  0, &val, &pos))
+    {
+      _dbus_warn ("Failed to parse double");
+      exit (1);
+    }
+  if (val != 0xff)
+    {
+      _dbus_warn ("Failed to parse 0xff correctly, got: %f", val);
+      exit (1);
+    }
+  if (pos != 4)
+    {
+      _dbus_warn ("_dbus_string_parse_double of \"0xff\" returned wrong position %d", pos);
+      exit (1);
+    }
+  
   check_path_absolute ("/", TRUE);
   check_path_absolute ("/foo", TRUE);
   check_path_absolute ("", FALSE);