summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-05 02:24:53 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-05 02:26:48 +0100
commit0dcd14b940e4a6c9904e11952c8a98e9152938f3 (patch)
tree69fe3b7ff2565c97a706ac9f44b419f74a422fc1 /src/libsystemd-bus/bus-message.c
parentb3e013148603aa670bc2c060ac63d48e54d76fc2 (diff)
bus: allow that if the destination pointer in sd_bus_message_read_basic() is NULL we skip over a field
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index bd0079dbb9..8cf273c380 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -2642,8 +2642,8 @@ static bool validate_object_path(const char *s, size_t l) {
int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
struct bus_container *c;
- int r;
void *q;
+ int r;
if (!m)
return -EINVAL;
@@ -2651,8 +2651,6 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
return -EPERM;
if (!bus_type_is_basic(type))
return -EINVAL;
- if (!p)
- return -EINVAL;
c = message_get_container(m);
@@ -2693,7 +2691,9 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
}
m->rindex = rindex;
- *(const char**) p = q;
+ if (p)
+ *(const char**) p = q;
+
break;
}
@@ -2717,7 +2717,9 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
return -EBADMSG;
m->rindex = rindex;
- *(const char**) p = q;
+
+ if (p)
+ *(const char**) p = q;
break;
}
@@ -2737,27 +2739,32 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
switch (type) {
case SD_BUS_TYPE_BYTE:
- *(uint8_t*) p = *(uint8_t*) q;
+ if (p)
+ *(uint8_t*) p = *(uint8_t*) q;
break;
case SD_BUS_TYPE_BOOLEAN:
- *(unsigned*) p = !!*(uint32_t*) q;
+ if (p)
+ *(unsigned*) p = !!*(uint32_t*) q;
break;
case SD_BUS_TYPE_INT16:
case SD_BUS_TYPE_UINT16:
- *(uint16_t*) p = BUS_MESSAGE_BSWAP16(m, *(uint16_t*) q);
+ if (p)
+ *(uint16_t*) p = BUS_MESSAGE_BSWAP16(m, *(uint16_t*) q);
break;
case SD_BUS_TYPE_INT32:
case SD_BUS_TYPE_UINT32:
- *(uint32_t*) p = BUS_MESSAGE_BSWAP32(m, *(uint32_t*) q);
+ if (p)
+ *(uint32_t*) p = BUS_MESSAGE_BSWAP32(m, *(uint32_t*) q);
break;
case SD_BUS_TYPE_INT64:
case SD_BUS_TYPE_UINT64:
case SD_BUS_TYPE_DOUBLE:
- *(uint64_t*) p = BUS_MESSAGE_BSWAP64(m, *(uint64_t*) q);
+ if (p)
+ *(uint64_t*) p = BUS_MESSAGE_BSWAP64(m, *(uint64_t*) q);
break;
case SD_BUS_TYPE_UNIX_FD: {
@@ -2767,7 +2774,8 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
if (j >= m->n_fds)
return -EBADMSG;
- *(int*) p = m->fds[j];
+ if (p)
+ *(int*) p = m->fds[j];
break;
}