From: Florian Forster Date: Tue, 7 Feb 2012 17:16:02 +0000 (+0100) Subject: write_graphite plugin: Fix trailing underscores. X-Git-Tag: collectd-5.1.0~33^2~10 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=acd2fa45d20e4445140fbad3dae7032019dff16b;p=collectd.git write_graphite plugin: Fix trailing underscores. This may also fix an off-by-one error when the name is long enough. D'oh! Change-Id: Ibc5a68f9bc93eed6366d074b55a7aca020bcf990 --- diff --git a/src/write_graphite.c b/src/write_graphite.c index cc4e38a3..fca40d1a 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -364,15 +364,18 @@ static void wg_copy_escape_part (char *dst, const char *src, size_t dst_len, for (i = 0; i < dst_len; i++) { + if (src[i] == 0) + { + dst[i] = 0; + break; + } + if ((src[i] == '.') || isspace ((int) src[i]) || iscntrl ((int) src[i])) dst[i] = escape_char; else dst[i] = src[i]; - - if (src[i] == 0) - break; } }