From aea179c7bbedd9e9dbbf54c8c9d772c5b26440dd Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 31 Jan 2009 23:28:21 +0100 Subject: [PATCH] libcollectdclient: Fix the SSTRCAT macro. The size passed to `strncat' is not the total size of the buffer, so GCC with _FORTIFY_SOURCE rightfully complained about this macro. Thanks to dD0T for reporting this :) --- src/libcollectdclient/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index c5be3b90..847eafc9 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -84,7 +84,8 @@ } while (0) #define SSTRCAT(d,s) do { \ - strncat ((d), (s), sizeof (d)); \ + size_t _l = strlen (d); \ + strncpy ((d) + _l, (s), sizeof (d) - _l); \ (d)[sizeof (d) - 1] = 0; \ } while (0) @@ -773,7 +774,7 @@ int lcc_putval (lcc_connection_t *c, const lcc_value_list_t *vl) /* {{{ */ int lcc_flush (lcc_connection_t *c, const char *plugin, /* {{{ */ lcc_identifier_t *ident, int timeout) { - char command[1024]; + char command[1024] = ""; lcc_response_t res; int status; -- 2.11.0