diff options
-rw-r--r-- | src/libsystemd-bus/bus-message.c | 11 | ||||
-rw-r--r-- | src/libsystemd-bus/test-bus-marshal.c | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index 9543ae3b26..4b53a6c509 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -1323,7 +1323,6 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void int r; assert_return(m, -EINVAL); - assert_return(p, -EINVAL); assert_return(!m->sealed, -EPERM); assert_return(bus_type_is_basic(type), -EINVAL); assert_return(!m->poisoned, -ESTALE); @@ -1380,6 +1379,11 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void break; case SD_BUS_TYPE_BOOLEAN: + if (!p) { + r = -EINVAL; + goto fail; + } + align = sz = 4; assert_cc(sizeof(int) == sizeof(uint32_t)); @@ -1391,6 +1395,11 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void case SD_BUS_TYPE_UNIX_FD: { int z, *f; + if (!p) { + r = -EINVAL; + goto fail; + } + if (!m->allow_fds) { r = -ENOTSUP; goto fail; diff --git a/src/libsystemd-bus/test-bus-marshal.c b/src/libsystemd-bus/test-bus-marshal.c index ae61476d57..5e29a7b6a2 100644 --- a/src/libsystemd-bus/test-bus-marshal.c +++ b/src/libsystemd-bus/test-bus-marshal.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *copy = NULL; int r, boolean; - const char *x, *y, *z, *a, *b, *c, *d; + const char *x, *x2, *y, *z, *a, *b, *c, *d; uint8_t u, v; void *buffer = NULL; size_t sz; @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) { assert_se(r >= 0); r = sd_bus_message_append(m, "s", NULL); - assert_se(r < 0); + assert_se(r >= 0); r = sd_bus_message_append(m, "as", 2, "string #1", "string #2"); assert_se(r >= 0); @@ -160,9 +160,10 @@ int main(int argc, char *argv[]) { assert_se(sd_bus_message_rewind(m, true) >= 0); - r = sd_bus_message_read(m, "sas", &x, 2, &y, &z); + r = sd_bus_message_read(m, "ssas", &x, &x2, 2, &y, &z); assert_se(r > 0); assert_se(streq(x, "a string")); + assert_se(streq(x2, "")); assert_se(streq(y, "string #1")); assert_se(streq(z, "string #2")); @@ -241,7 +242,7 @@ int main(int argc, char *argv[]) { assert_se(sd_bus_message_verify_type(m, 's', NULL) > 0); - r = sd_bus_message_skip(m, "sas"); + r = sd_bus_message_skip(m, "ssas"); assert_se(r > 0); assert_se(sd_bus_message_verify_type(m, 's', NULL) > 0); |