summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-06 02:01:43 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-06 02:31:35 +0100
commitcd6f997f71c3aba16aa08226d423d14cbc787f82 (patch)
tree66ca8c8fe9cc671b0b63043ae6a35e1f0d06c2d2 /src/libsystemd-bus/bus-message.c
parent41f85451d36f14bfc2f78e687167eba9a2d4d67c (diff)
bus: handle serialization of NULL strings
Instead of simply crashing be somewhat nicer and serialize a NULL string into the empty string and generate an error on signature and object path strings.
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index e68b43bbae..437f6dfd49 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -1347,14 +1347,29 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void
switch (type) {
case SD_BUS_TYPE_STRING:
+ /* To make things easy we'll serialize a NULL string
+ * into the empty string */
+ p = strempty(p);
+
+ /* Fall through... */
case SD_BUS_TYPE_OBJECT_PATH:
+ if (!p) {
+ r = -EINVAL;
+ goto fail;
+ }
+
align = 4;
sz = 4 + strlen(p) + 1;
break;
case SD_BUS_TYPE_SIGNATURE:
+ if (!p) {
+ r = -EINVAL;
+ goto fail;
+ }
+
align = 1;
sz = 1 + strlen(p) + 1;
break;