From: Florian Forster Date: Tue, 2 May 2017 08:26:40 +0000 (+0200) Subject: libcollectdclient: Fix off-by-one error when reading the username. X-Git-Tag: collectd-5.8.0~102^2~16 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=59353d13d73f3a351c5dada73896344b9e2a3818;p=collectd.git libcollectdclient: Fix off-by-one error when reading the username. The allocated buffer includes a null byte, but the network packet doesn't. That means we were reading one byte too many from the buffer, overwriting the terminating null byte in the buffer. --- diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 7139c9bc..83a05d4f 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -441,7 +441,7 @@ static int parse_encrypt_aes256(void *data, size_t data_size, return ENOMEM; char username[((size_t)username_len) + 1]; memset(username, 0, sizeof(username)); - if (buffer_next(b, username, sizeof(username))) + if (buffer_next(b, username, (size_t)username_len)) return EINVAL; char const *password = opts->password_lookup(username);