Marshalling of empty string, object_path, signatures and NUL byte

Simon McVittie simon.mcvittie at
Wed May 25 15:43:11 UTC 2016

On 25/05/16 09:06, marcin at wrote:
> what is the correct approach to marshall empty strings, object paths and
> sinatures? (with length == 0)?
> Should it contain just NUL byte after length of just length alone?

I'm fairly sure empty strings aren't special. Non-empty strings are
marshalled as a length, followed by some data, followed by a NUL; empty
strings are marshalled as a length, followed by no data, followed by a NUL.

(Strings are encoded this way so that a C implementation like libdbus
can point directly into the message buffer and get a NUL-terminated
const char * that it can provide to the library user, without having to
memcpy it out.)

If in doubt, look at what the D-Bus Specification says, or at what a
high-quality interoperable implementation (for instance libdbus, GDBus,
sd-bus) emits.

Simon McVittie
Collabora Ltd. <>

More information about the dbus mailing list