GNU bug report logs -
#43252
27.1; DBus properties lack type hints or overrides
Previous Next
Reported by: Hugh Daschbach <hugh <at> ccss.com>
Date: Mon, 7 Sep 2020 00:55:02 UTC
Severity: normal
Found in version 27.1
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hugh Daschbach <hugh <at> ccss.com> writes:
Hi Hugh,
>>> +
>>> + (should ; Should this error
>>> instead?
>>> + (equal
>>> + (dbus-set-property
>>> ...
>>> + '(:array "seven" "eight" :string "nine"))
>>
>> Good question. dbus-set-property and dbus-get-property do not
>> propagate
>> D-Bus errors. Maybe we shall change the functions to do so? I've
>> asked
>> this already myself.
>
> I don't have a strong opinion either way. I'm just trying to note
> corner cases.
Well, I have adapted dbus-set-property and dbus-get-property to
propagate the errors.
>>> + ;; Test mismatched types in array
>>> +
>>> + (should ; Oddly enough, register
>>> works, but get fails
>>> + (equal
>>
>> Hmm, yes. dbus-register-property does not perform a local type
>> check. And honestly, I don't want to do it; I let the D-Bus daemon
>> do
>> the job.
>
> Great.
Should be checked now. When dbus-register-property is called, it applies
internally a dbus-set-property or dbus-get-property now. As side effect,
the value is checked by the D-Bus daemon, and you shall see errors.
>> And even if you would have prefixed the value with :byte, there
>> won't be
>> an error. In dbusbind.c, byte values are simply computed by taking
>> the
>> modulo 255:
>>
>> unsigned char val = XFIXNAT (object) & 0xFF;
>>
>> ":byte 1024" is equal to ":byte 4". Similar conversions happen for
>> the
>> other basic types, based on numbers.
>
> Good. I haven't thought deeply enough about DBus to anticipate
> truncation. I've added a test for this, an extract of which is below.
> The get returns nil instead of 4. I can change the expected value,
> but
> wanted to run this by you first.
Of course I'm wrong, ":byte 1024" shall be the same as "byte 0".
> (ert-deftest dbus-test-ad-hoc ()
> (dbus-ignore-errors (dbus-unregister-service :session
> dbus--test-service))
> (dbus-register-service :session dbus--test-service)
> (should ; Test value truncation
> (equal
> (dbus-register-property
> :session dbus--test-service dbus--test-path
> dbus--test-interface "ByteValue" :read :byte 1024)
> `((:property :session ,dbus--test-interface "ByteValue")
> (,dbus--test-service ,dbus--test-path))))
>
> (should ; Returns 0 instead of 4.
> (equal
> (dbus-get-property
> :session dbus--test-service dbus--test-path
> dbus--test-interface "ByteValue")
> 4))
Of course 0. As said, I was wrong.
> (dbus-unregister-service :session dbus--test-service))
>
> Should I update the expectation to zero?
Yes, please.
> Cheers,
> Hugh
Best regards, Michael.
This bug report was last modified 4 years and 229 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.