From: Florian Forster Date: Sat, 31 Jan 2009 22:28:21 +0000 (+0100) Subject: libcollectdclient: Fix the SSTRCAT macro. X-Git-Tag: collectd-4.6.0~92 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=aea179c7bbedd9e9dbbf54c8c9d772c5b26440dd;p=collectd.git 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 :) --- 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;