aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2020-09-29 19:43:02 +0200
committerMichael Albinus2020-09-29 19:43:02 +0200
commit7e45ed3a9674e9f436c337bed647ce9f60939ee0 (patch)
tree60c51def12fcbce14fb69e5f0cf2454d5356c9fd /src
parent7f2c35d02874129723cc5e89d54cc3ab5bf07a31 (diff)
downloademacs-7e45ed3a9674e9f436c337bed647ce9f60939ee0.tar.gz
emacs-7e45ed3a9674e9f436c337bed647ce9f60939ee0.zip
More strict D-Bus type checking
* lisp/net/dbus.el (dbus-register-monitor): Register proper key. (dbus-monitor-handler): Adapt docstring. Use grave text-quoting-style. * src/dbusbind.c (xd_signature, xd_append_arg): More strict tests. (syms_of_dbusbind): Adapt docstring. * test/lisp/net/dbus-tests.el (dbus-test01-basic-types): Extend test.
Diffstat (limited to 'src')
-rw-r--r--src/dbusbind.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 09f0317be91..b06077d3b58 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -380,8 +380,9 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
380 break; 380 break;
381 381
382 case DBUS_TYPE_BOOLEAN: 382 case DBUS_TYPE_BOOLEAN:
383 /* Any non-nil object will be regarded as `t', so we don't apply 383 /* There must be an argument. */
384 further type check. */ 384 if (EQ (QCboolean, object))
385 wrong_type_argument (intern ("booleanp"), object);
385 sprintf (signature, "%c", dtype); 386 sprintf (signature, "%c", dtype);
386 break; 387 break;
387 388
@@ -405,6 +406,8 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
405 case DBUS_TYPE_STRING: 406 case DBUS_TYPE_STRING:
406 case DBUS_TYPE_OBJECT_PATH: 407 case DBUS_TYPE_OBJECT_PATH:
407 case DBUS_TYPE_SIGNATURE: 408 case DBUS_TYPE_SIGNATURE:
409 /* We dont check the syntax of object path and signature. This
410 will be done by libdbus. */
408 CHECK_STRING (object); 411 CHECK_STRING (object);
409 sprintf (signature, "%c", dtype); 412 sprintf (signature, "%c", dtype);
410 break; 413 break;
@@ -615,6 +618,9 @@ xd_append_arg (int dtype, Lisp_Object object, DBusMessageIter *iter)
615 } 618 }
616 619
617 case DBUS_TYPE_BOOLEAN: 620 case DBUS_TYPE_BOOLEAN:
621 /* There must be an argument. */
622 if (EQ (QCboolean, object))
623 wrong_type_argument (intern ("booleanp"), object);
618 { 624 {
619 dbus_bool_t val = (NILP (object)) ? FALSE : TRUE; 625 dbus_bool_t val = (NILP (object)) ? FALSE : TRUE;
620 XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true"); 626 XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
@@ -713,6 +719,8 @@ xd_append_arg (int dtype, Lisp_Object object, DBusMessageIter *iter)
713 case DBUS_TYPE_STRING: 719 case DBUS_TYPE_STRING:
714 case DBUS_TYPE_OBJECT_PATH: 720 case DBUS_TYPE_OBJECT_PATH:
715 case DBUS_TYPE_SIGNATURE: 721 case DBUS_TYPE_SIGNATURE:
722 /* We dont check the syntax of object path and signature.
723 This will be done by libdbus. */
716 CHECK_STRING (object); 724 CHECK_STRING (object);
717 { 725 {
718 /* We need to send a valid UTF-8 string. We could encode `object' 726 /* We need to send a valid UTF-8 string. We could encode `object'
@@ -1927,11 +1935,11 @@ and for calling handlers in case of non-blocking method call returns.
1927 1935
1928In the first case, the key in the hash table is the list (TYPE BUS 1936In the first case, the key in the hash table is the list (TYPE BUS
1929INTERFACE MEMBER). TYPE is one of the Lisp symbols `:method', 1937INTERFACE MEMBER). TYPE is one of the Lisp symbols `:method',
1930`:signal' or `:property'. BUS is either a Lisp symbol, `:system' or 1938`:signal', `:property' or `:monitor'. BUS is either a Lisp symbol,
1931`:session', or a string denoting the bus address. INTERFACE is a 1939`:system', `:session', `:system-private' or `:session-private', or a
1932string which denotes a D-Bus interface, and MEMBER, also a string, is 1940string denoting the bus address. INTERFACE is a string which denotes
1933either a method, a signal or a property INTERFACE is offering. All 1941a D-Bus interface, and MEMBER, also a string, is either a method, a
1934arguments but BUS must not be nil. 1942signal or a property INTERFACE is offering. All arguments can be nil.
1935 1943
1936The value in the hash table is a list of quadruple lists ((UNAME 1944The value in the hash table is a list of quadruple lists ((UNAME
1937SERVICE PATH OBJECT [RULE]) ...). SERVICE is the service name as 1945SERVICE PATH OBJECT [RULE]) ...). SERVICE is the service name as