diff --git a/src/utils/proto.c b/src/utils/proto.c
index beaa07e98397f18876f27952ab38ed83ff673638..f767fa21a887fdd929a32ea45f16fec656ff6b5f 100644 (file)
--- a/src/utils/proto.c
+++ b/src/utils/proto.c
marshal_binary(char *buf, size_t buf_len, size_t len, const unsigned char *v)
{
uint32_t tmp = htonl((uint32_t)len);
- if (buf_len >= len) {
+ if (buf_len >= sizeof(tmp) + len) {
memcpy(buf, &tmp, sizeof(tmp));
memcpy(buf + sizeof(tmp), v, len);
}
marshal_string(char *buf, size_t buf_len, const char *v)
{
/* The actual string including the terminating null byte. */
- return marshal_binary(buf, buf_len,
- strlen(v) + 1, (const unsigned char *)v);
+ size_t len = strlen(v) + 1;
+ if (buf_len >= len)
+ memcpy(buf, v, len);
+ return len;
} /* marshal_string */
/*