Is there a hard limit on dbus string size?

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Apr 15 03:07:45 PDT 2010


On Thu, 15 Apr 2010 at 10:48:50 +0100, Will Thompson wrote:
> On 15/04/10 10:36, Ryan Heniser wrote:
> >Can't find it in the docs. So, I'd assume the size is limited by memory
> >size, like most string implementations.

<http://dbus.freedesktop.org/doc/dbus-specification.html> says:

"Given all this, the types are marshaled on the wire as follows:
...
STRING. A UINT32 indicating the string's length in bytes excluding its
terminating nul, followed by non-nul string data of the given length,
followed by a terminating nul byte."

so you have a 2**32 byte limit imposed by the serialization format; but in a
D-Bus message,

"The maximum length of a message, including header, header alignment
padding, and body is 2 to the 27th power or 134217728"

which is 128MB.

The default session bus configuration allows messages this large (actually
larger, but I suspect the 128MB limit is also enforced):

/etc/dbus-1/session.conf:
  <limit name="max_message_size">1000000000</limit>

but the default system bus configuration does not override the hard-coded
default of 32MB, which limits it further:

bus/bus.c:
      parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;

(yes, this would be more visible if system.conf explicitly repeated all the
default settings).

> (But I'm suspicious of passing 3MB strings over D-Bus. :))

What Will said - there is likely to be a way to do this that doesn't involve
copying the string into the D-Bus daemon, then back out into the client,
checking it for UTF-8 validity at each step.

Regards,
    Simon


More information about the dbus mailing list