aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-06 23:08:48 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-06 23:08:51 +0200
commitf60bc82c1210cd6f18f0f8d5d9e1f57750810bb0 (patch)
treee1b1f7aac5bb11f747be1740369538581c2a9aee /src
parentprint pid of mds-server (diff)
downloadmds-f60bc82c1210cd6f18f0f8d5d9e1f57750810bb0.tar.gz
mds-f60bc82c1210cd6f18f0f8d5d9e1f57750810bb0.tar.bz2
mds-f60bc82c1210cd6f18f0f8d5d9e1f57750810bb0.tar.xz
add some zero length checks
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-server/multicast.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mds-server/multicast.c b/src/mds-server/multicast.c
index 21c9e60..a901194 100644
--- a/src/mds-server/multicast.c
+++ b/src/mds-server/multicast.c
@@ -93,8 +93,11 @@ size_t multicast_marshal(const multicast_t* restrict this, char* restrict data)
data += n / sizeof(char);
rc += n;
}
- memcpy(data, this->message, this->message_length * sizeof(char));
- rc += this->message_length * sizeof(char);
+ if (this->message_length > 0)
+ {
+ memcpy(data, this->message, this->message_length * sizeof(char));
+ rc += this->message_length * sizeof(char);
+ }
return rc;
}
@@ -120,18 +123,22 @@ size_t multicast_unmarshal(multicast_t* restrict this, char* restrict data)
buf_get_next(data, size_t, this->message_length);
buf_get_next(data, size_t, this->message_ptr);
buf_get_next(data, size_t, this->message_prefix);
- if (xmalloc(this->interceptions, this->interceptions_count, queued_interception_t))
- return 0;
+ if (this->interceptions_count > 0)
+ if (xmalloc(this->interceptions, this->interceptions_count, queued_interception_t))
+ return 0;
for (i = 0; i < this->interceptions_count; i++)
{
n = queued_interception_unmarshal(this->interceptions + i, data);
data += n / sizeof(char);
rc += n;
}
- if (xmalloc(this->message, this->message_length, char))
- return 0;
- memcpy(this->message, data, this->message_length * sizeof(char));
- rc += this->message_length * sizeof(char);
+ if (this->message_length > 0)
+ {
+ if (xmalloc(this->message, this->message_length, char))
+ return 0;
+ memcpy(this->message, data, this->message_length * sizeof(char));
+ rc += this->message_length * sizeof(char);
+ }
return rc;
}