changeset 108945:998fccafba7a

* dbusbind.c (xd_append_arg): Don't "make-unibyte" the string. Check `object's type before accessing its guts.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 09 Jun 2010 10:31:12 -0400
parents b9c2b845f2e6
children d418516def73 c0520c9cf957
files src/ChangeLog src/config.in src/dbusbind.c
diffstat 3 files changed, 53 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Jun 08 21:18:31 2010 -0400
+++ b/src/ChangeLog	Wed Jun 09 10:31:12 2010 -0400
@@ -1,3 +1,8 @@
+2010-06-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* dbusbind.c (xd_append_arg): Don't "make-unibyte" the string.
+	Check `object's type before accessing its guts.
+
 2010-06-08  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* minibuf.c (Fall_completions): Add more checks.
--- a/src/config.in	Tue Jun 08 21:18:31 2010 -0400
+++ b/src/config.in	Wed Jun 09 10:31:12 2010 -0400
@@ -319,10 +319,10 @@
 /* Define to 1 if you have the <kerberos/krb.h> header file. */
 #undef HAVE_KERBEROS_KRB_H
 
-/* Define to 1 if `e_text' is member of `krb5_error'. */
+/* Define to 1 if `e_text' is a member of `krb5_error'. */
 #undef HAVE_KRB5_ERROR_E_TEXT
 
-/* Define to 1 if `text' is member of `krb5_error'. */
+/* Define to 1 if `text' is a member of `krb5_error'. */
 #undef HAVE_KRB5_ERROR_TEXT
 
 /* Define to 1 if you have the <krb5.h> header file. */
@@ -616,25 +616,25 @@
 /* Define to 1 if you have the `strsignal' function. */
 #undef HAVE_STRSIGNAL
 
-/* Define to 1 if `ifr_addr' is member of `struct ifreq'. */
+/* Define to 1 if `ifr_addr' is a member of `struct ifreq'. */
 #undef HAVE_STRUCT_IFREQ_IFR_ADDR
 
-/* Define to 1 if `ifr_broadaddr' is member of `struct ifreq'. */
+/* Define to 1 if `ifr_broadaddr' is a member of `struct ifreq'. */
 #undef HAVE_STRUCT_IFREQ_IFR_BROADADDR
 
-/* Define to 1 if `ifr_flags' is member of `struct ifreq'. */
+/* Define to 1 if `ifr_flags' is a member of `struct ifreq'. */
 #undef HAVE_STRUCT_IFREQ_IFR_FLAGS
 
-/* Define to 1 if `ifr_hwaddr' is member of `struct ifreq'. */
+/* Define to 1 if `ifr_hwaddr' is a member of `struct ifreq'. */
 #undef HAVE_STRUCT_IFREQ_IFR_HWADDR
 
-/* Define to 1 if `ifr_netmask' is member of `struct ifreq'. */
+/* Define to 1 if `ifr_netmask' is a member of `struct ifreq'. */
 #undef HAVE_STRUCT_IFREQ_IFR_NETMASK
 
-/* Define to 1 if `n_un.n_name' is member of `struct nlist'. */
+/* Define to 1 if `n_un.n_name' is a member of `struct nlist'. */
 #undef HAVE_STRUCT_NLIST_N_UN_N_NAME
 
-/* Define to 1 if `tm_zone' is member of `struct tm'. */
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
 #undef HAVE_STRUCT_TM_TM_ZONE
 
 /* Define to 1 if `struct utimbuf' is declared by <utime.h>. */
@@ -858,6 +858,9 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -917,6 +920,28 @@
 /* Define to 1 if using the Motif X toolkit. */
 #undef USE_MOTIF
 
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
 /* Define to 1 if we should use toolkit scroll bars. */
 #undef USE_TOOLKIT_SCROLL_BARS
 
@@ -952,28 +977,6 @@
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
 
-/* Enable extensions on AIX 3, Interix.  */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif
-/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif
-/* Enable threading extensions on Solaris.  */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-/* Enable extensions on HP NonStop.  */
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-/* Enable general extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-
-
 /* Define to rpl_ if the getopt replacement functions and variables should be
    used. */
 #undef __GETOPT_PREFIX
--- a/src/dbusbind.c	Tue Jun 08 21:18:31 2010 -0400
+++ b/src/dbusbind.c	Wed Jun 09 10:31:12 2010 -0400
@@ -405,6 +405,7 @@
     switch (dtype)
       {
       case DBUS_TYPE_BYTE:
+	CHECK_NUMBER (object);
 	{
 	  unsigned char val = XUINT (object) & 0xFF;
 	  XD_DEBUG_MESSAGE ("%c %d", dtype, val);
@@ -423,6 +424,7 @@
 	}
 
       case DBUS_TYPE_INT16:
+	CHECK_NUMBER (object);
 	{
 	  dbus_int16_t val = XINT (object);
 	  XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
@@ -432,6 +434,7 @@
 	}
 
       case DBUS_TYPE_UINT16:
+	CHECK_NUMBER (object);
 	{
 	  dbus_uint16_t val = XUINT (object);
 	  XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
@@ -441,6 +444,7 @@
 	}
 
       case DBUS_TYPE_INT32:
+	CHECK_NUMBER (object);
 	{
 	  dbus_int32_t val = XINT (object);
 	  XD_DEBUG_MESSAGE ("%c %d", dtype, val);
@@ -450,6 +454,7 @@
 	}
 
       case DBUS_TYPE_UINT32:
+	CHECK_NUMBER (object);
 	{
 	  dbus_uint32_t val = XUINT (object);
 	  XD_DEBUG_MESSAGE ("%c %u", dtype, val);
@@ -459,6 +464,7 @@
 	}
 
       case DBUS_TYPE_INT64:
+	CHECK_NUMBER (object);
 	{
 	  dbus_int64_t val = XINT (object);
 	  XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
@@ -468,6 +474,7 @@
 	}
 
       case DBUS_TYPE_UINT64:
+	CHECK_NUMBER (object);
 	{
 	  dbus_uint64_t val = XUINT (object);
 	  XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
@@ -477,6 +484,7 @@
 	}
 
       case DBUS_TYPE_DOUBLE:
+	CHECK_FLOAT (object);
 	{
 	  double val = XFLOAT_DATA (object);
 	  XD_DEBUG_MESSAGE ("%c %f", dtype, val);
@@ -488,8 +496,13 @@
       case DBUS_TYPE_STRING:
       case DBUS_TYPE_OBJECT_PATH:
       case DBUS_TYPE_SIGNATURE:
+	CHECK_STRING (object);
 	{
-	  char *val = SDATA (Fstring_make_unibyte (object));
+	  /* We need to send a valid UTF-8 string.  We could encode `object'
+	     but by not encoding it, we guarantee it's valid utf-8, even if
+	     it contains eight-bit-bytes.  Of course, you can still send
+	     manually-crafted junk by passing a unibyte string.  */
+	  char *val = SDATA (object);
 	  XD_DEBUG_MESSAGE ("%c %s", dtype, val);
 	  if (!dbus_message_iter_append_basic (iter, dtype, &val))
 	    XD_SIGNAL2 (build_string ("Unable to append argument"), object);