Mercurial > emacs
comparison src/dbusbind.c @ 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 | 1d1d5d9bd884 |
| children | d418516def73 a14b02ae1413 |
comparison
equal
deleted
inserted
replaced
| 108944:b9c2b845f2e6 | 108945:998fccafba7a |
|---|---|
| 403 | 403 |
| 404 if (XD_BASIC_DBUS_TYPE (dtype)) | 404 if (XD_BASIC_DBUS_TYPE (dtype)) |
| 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); |
| 411 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 412 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 412 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 413 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 421 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 422 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 422 return; | 423 return; |
| 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); |
| 429 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 431 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 430 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 432 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 431 return; | 433 return; |
| 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); |
| 438 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 441 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 439 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 442 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 440 return; | 443 return; |
| 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); |
| 447 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 451 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 448 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 452 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 449 return; | 453 return; |
| 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); |
| 456 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 461 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 457 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 462 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 458 return; | 463 return; |
| 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); |
| 465 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 471 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 466 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 472 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 467 return; | 473 return; |
| 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); |
| 474 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 481 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 475 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 482 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 476 return; | 483 return; |
| 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); |
| 483 if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 491 if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 484 XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 492 XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 486 } | 494 } |
| 487 | 495 |
| 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: |
| 491 { | 499 CHECK_STRING (object); |
| 492 char *val = SDATA (Fstring_make_unibyte (object)); | 500 { |
| 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); |
| 496 return; | 509 return; |
| 497 } | 510 } |
