aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorStefan Monnier2010-06-09 10:31:12 -0400
committerStefan Monnier2010-06-09 10:31:12 -0400
commite454a4a330cc6524cf0d2604b4fafc32d5bda795 (patch)
tree5ea60e93a09269c33ddf13e44a43dcac225c03f4 /src/dbusbind.c
parent989bc97f04f8143a7ab51088f9861da8d5df45f1 (diff)
downloademacs-e454a4a330cc6524cf0d2604b4fafc32d5bda795.tar.gz
emacs-e454a4a330cc6524cf0d2604b4fafc32d5bda795.zip
* dbusbind.c (xd_append_arg): Don't "make-unibyte" the string.
Check `object's type before accessing its guts.
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 5cad182b525..f710741b591 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -405,6 +405,7 @@ xd_append_arg (dtype, object, iter)
405 switch (dtype) 405 switch (dtype)
406 { 406 {
407 case DBUS_TYPE_BYTE: 407 case DBUS_TYPE_BYTE:
408 CHECK_NUMBER (object);
408 { 409 {
409 unsigned char val = XUINT (object) & 0xFF; 410 unsigned char val = XUINT (object) & 0xFF;
410 XD_DEBUG_MESSAGE ("%c %d", dtype, val); 411 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
@@ -423,6 +424,7 @@ xd_append_arg (dtype, object, iter)
423 } 424 }
424 425
425 case DBUS_TYPE_INT16: 426 case DBUS_TYPE_INT16:
427 CHECK_NUMBER (object);
426 { 428 {
427 dbus_int16_t val = XINT (object); 429 dbus_int16_t val = XINT (object);
428 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); 430 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
@@ -432,6 +434,7 @@ xd_append_arg (dtype, object, iter)
432 } 434 }
433 435
434 case DBUS_TYPE_UINT16: 436 case DBUS_TYPE_UINT16:
437 CHECK_NUMBER (object);
435 { 438 {
436 dbus_uint16_t val = XUINT (object); 439 dbus_uint16_t val = XUINT (object);
437 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); 440 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
@@ -441,6 +444,7 @@ xd_append_arg (dtype, object, iter)
441 } 444 }
442 445
443 case DBUS_TYPE_INT32: 446 case DBUS_TYPE_INT32:
447 CHECK_NUMBER (object);
444 { 448 {
445 dbus_int32_t val = XINT (object); 449 dbus_int32_t val = XINT (object);
446 XD_DEBUG_MESSAGE ("%c %d", dtype, val); 450 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
@@ -450,6 +454,7 @@ xd_append_arg (dtype, object, iter)
450 } 454 }
451 455
452 case DBUS_TYPE_UINT32: 456 case DBUS_TYPE_UINT32:
457 CHECK_NUMBER (object);
453 { 458 {
454 dbus_uint32_t val = XUINT (object); 459 dbus_uint32_t val = XUINT (object);
455 XD_DEBUG_MESSAGE ("%c %u", dtype, val); 460 XD_DEBUG_MESSAGE ("%c %u", dtype, val);
@@ -459,6 +464,7 @@ xd_append_arg (dtype, object, iter)
459 } 464 }
460 465
461 case DBUS_TYPE_INT64: 466 case DBUS_TYPE_INT64:
467 CHECK_NUMBER (object);
462 { 468 {
463 dbus_int64_t val = XINT (object); 469 dbus_int64_t val = XINT (object);
464 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); 470 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
@@ -468,6 +474,7 @@ xd_append_arg (dtype, object, iter)
468 } 474 }
469 475
470 case DBUS_TYPE_UINT64: 476 case DBUS_TYPE_UINT64:
477 CHECK_NUMBER (object);
471 { 478 {
472 dbus_uint64_t val = XUINT (object); 479 dbus_uint64_t val = XUINT (object);
473 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); 480 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
@@ -477,6 +484,7 @@ xd_append_arg (dtype, object, iter)
477 } 484 }
478 485
479 case DBUS_TYPE_DOUBLE: 486 case DBUS_TYPE_DOUBLE:
487 CHECK_FLOAT (object);
480 { 488 {
481 double val = XFLOAT_DATA (object); 489 double val = XFLOAT_DATA (object);
482 XD_DEBUG_MESSAGE ("%c %f", dtype, val); 490 XD_DEBUG_MESSAGE ("%c %f", dtype, val);
@@ -488,8 +496,13 @@ xd_append_arg (dtype, object, iter)
488 case DBUS_TYPE_STRING: 496 case DBUS_TYPE_STRING:
489 case DBUS_TYPE_OBJECT_PATH: 497 case DBUS_TYPE_OBJECT_PATH:
490 case DBUS_TYPE_SIGNATURE: 498 case DBUS_TYPE_SIGNATURE:
499 CHECK_STRING (object);
491 { 500 {
492 char *val = SDATA (Fstring_make_unibyte (object)); 501 /* We need to send a valid UTF-8 string. We could encode `object'
502 but by not encoding it, we guarantee it's valid utf-8, even if
503 it contains eight-bit-bytes. Of course, you can still send
504 manually-crafted junk by passing a unibyte string. */
505 char *val = SDATA (object);
493 XD_DEBUG_MESSAGE ("%c %s", dtype, val); 506 XD_DEBUG_MESSAGE ("%c %s", dtype, val);
494 if (!dbus_message_iter_append_basic (iter, dtype, &val)) 507 if (!dbus_message_iter_append_basic (iter, dtype, &val))
495 XD_SIGNAL2 (build_string ("Unable to append argument"), object); 508 XD_SIGNAL2 (build_string ("Unable to append argument"), object);