diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-11 14:02:59 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-11 14:02:59 +0200 |
commit | cfcc0059bfb8be7d1da80cb6a75d9ba71f4662f7 (patch) | |
tree | 5601f3ea6dfddc468dfbfddcff529a3c9b554b4e /src | |
parent | f0ae945ecc4631c538b845d807a60c5b72903a5b (diff) | |
download | systemd-cfcc0059bfb8be7d1da80cb6a75d9ba71f4662f7.tar.gz |
sd-bus: add define for the maximum signature length
Less magic numbers in the code…
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-signature.c | 2 | ||||
-rw-r--r-- | src/systemd/sd-bus.h | 3 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index a2464e1a46..427d42f296 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -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" */ diff --git a/src/libsystemd/sd-bus/bus-signature.c b/src/libsystemd/sd-bus/bus-signature.c index 1ecd6e8b7e..b420ba3688 100644 --- a/src/libsystemd/sd-bus/bus-signature.c +++ b/src/libsystemd/sd-bus/bus-signature.c @@ -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; } diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 129cc93328..311602d048 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -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; |