X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fnetwork_parse.c;h=14e8be57a743e0ef11423ba850da4b8ad1ba9a45;hb=28c83da870b4df4a311a5ef20a5ca37d3c84c638;hp=91fe18de1a5a5f37164c28d7bfc1d2331fffc961;hpb=7b0628b4f4688d48d89f94ca381ca6340da05b37;p=collectd.git diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 91fe18de..14e8be57 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -46,7 +46,7 @@ #elif HAVE_SYS_ENDIAN_H #include #else /* fallback */ -#include "stdendian.h" +#include "collectd/stdendian.h" #endif #if HAVE_GCRYPT_H @@ -158,7 +158,8 @@ static int parse_string(void *payload, size_t payload_size, char *out, (payload_size > out_size)) return EINVAL; - strncpy(out, in, out_size); + strncpy(out, in, out_size - 1); + out[out_size - 1] = '\0'; return 0; } @@ -221,7 +222,7 @@ static int parse_time(uint16_t type, void *payload, size_t payload_size, static double ntohd(double val) /* {{{ */ { - static int config = 0; + static int config; union { uint8_t byte[8]; @@ -303,8 +304,8 @@ static int parse_values(void *payload, size_t payload_size, return EINVAL; state->values_len = (size_t)n; - state->values = calloc(sizeof(*state->values), state->values_len); - state->values_types = calloc(sizeof(*state->values_types), state->values_len); + state->values = calloc(state->values_len, sizeof(*state->values)); + state->values_types = calloc(state->values_len, sizeof(*state->values_types)); if ((state->values == NULL) || (state->values_types == NULL)) { return ENOMEM; }