mirror of
https://github.com/systemd/systemd
synced 2024-10-15 20:45:09 +00:00
sd-bus: add define for the maximum signature length
Less magic numbers in the code…
This commit is contained in:
parent
f0ae945ecc
commit
cfcc0059bf
|
@ -284,7 +284,7 @@ static int message_append_field_signature(
|
|||
/* dbus1 doesn't allow signatures over 8bit, let's enforce
|
||||
* this globally, to not risk convertability */
|
||||
l = strlen(s);
|
||||
if (l > 255)
|
||||
if (l > SD_BUS_MAXIMUM_SIGNATURE_LENGTH)
|
||||
return -EINVAL;
|
||||
|
||||
/* Signature "(yv)" where the variant contains "g" */
|
||||
|
|
|
@ -144,5 +144,5 @@ bool signature_is_valid(const char *s, bool allow_dict_entry) {
|
|||
p += t;
|
||||
}
|
||||
|
||||
return p - s <= 255;
|
||||
return p - s <= SD_BUS_MAXIMUM_SIGNATURE_LENGTH;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ _SD_BEGIN_DECLARATIONS;
|
|||
#define SD_BUS_DEFAULT_USER ((sd_bus *) 2)
|
||||
#define SD_BUS_DEFAULT_SYSTEM ((sd_bus *) 3)
|
||||
|
||||
/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature */
|
||||
#define SD_BUS_MAXIMUM_SIGNATURE_LENGTH 255
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef struct sd_bus sd_bus;
|
||||
|
|
Loading…
Reference in a new issue