diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-06-07 05:41:26 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-06-07 05:41:26 +0200 |
commit | f20b015724f082c278a85853954ec94055fe0b02 (patch) | |
tree | 3a73147ef9ce898991ff640d25a5adf375426fd4 /src | |
parent | add zero length check (diff) | |
download | mds-f20b015724f082c278a85853954ec94055fe0b02.tar.gz mds-f20b015724f082c278a85853954ec94055fe0b02.tar.bz2 mds-f20b015724f082c278a85853954ec94055fe0b02.tar.xz |
fix some client marshalling errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds-server/client.c | 5 | ||||
-rw-r--r-- | src/mds-server/interception-condition.c | 4 | ||||
-rw-r--r-- | src/mds-server/multicast.c | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/mds-server/client.c b/src/mds-server/client.c index f927cb1..f9244ef 100644 --- a/src/mds-server/client.c +++ b/src/mds-server/client.c @@ -172,11 +172,12 @@ size_t client_marshal(const client_t* restrict this, char* restrict data) buf_set_next(data, uint64_t, this->id); n = mds_message_marshal_size(&(this->message)); buf_set_next(data, size_t, n); - mds_message_marshal(&(this->message), data); + if (n > 0) + mds_message_marshal(&(this->message), data); data += n / sizeof(char); buf_set_next(data, size_t, this->interception_conditions_count); for (i = 0; i < this->interception_conditions_count; i++) - data += interception_condition_marshal(this->interception_conditions + i, data) / sizeof(char); + data += n = interception_condition_marshal(this->interception_conditions + i, data) / sizeof(char); buf_set_next(data, size_t, this->multicasts_count); for (i = 0; i < this->multicasts_count; i++) data += multicast_marshal(this->multicasts + i, data) / sizeof(char); diff --git a/src/mds-server/interception-condition.c b/src/mds-server/interception-condition.c index b625b2e..091a6e5 100644 --- a/src/mds-server/interception-condition.c +++ b/src/mds-server/interception-condition.c @@ -74,7 +74,7 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this, if ((this->condition = malloc(n)) == NULL) return 0; memcpy(this->condition, data, n); - return sizeof(size_t) + sizeof(int64_t) + sizeof(int) + n; + return sizeof(size_t) + sizeof(int64_t) + 2 * sizeof(int) + n; } @@ -86,7 +86,7 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this, */ size_t interception_condition_unmarshal_skip(char* restrict data) { - size_t n = sizeof(size_t) + sizeof(int64_t) + sizeof(int); + size_t n = sizeof(size_t) + sizeof(int64_t) + 2 * sizeof(int); buf_next(data, int, 1); buf_next(data, size_t, 1); buf_next(data, int64_t, 1); diff --git a/src/mds-server/multicast.c b/src/mds-server/multicast.c index e6f38fe..7d92eba 100644 --- a/src/mds-server/multicast.c +++ b/src/mds-server/multicast.c @@ -112,7 +112,7 @@ size_t multicast_marshal(const multicast_t* restrict this, char* restrict data) */ size_t multicast_unmarshal(multicast_t* restrict this, char* restrict data) { - size_t rc = 5 * sizeof(size_t); + size_t rc = sizeof(int) + 5 * sizeof(size_t); size_t i, n; this->interceptions = NULL; this->message = NULL; |