From: daryder Date: Mon, 3 Nov 2014 20:55:15 +0000 (-0500) Subject: Change strcat to strncat X-Git-Tag: collectd-5.5.0~80^2~7 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6f0fb094a2c7e5bea41c5914799e06d7025f5e2b;p=collectd.git Change strcat to strncat --- diff --git a/src/ceph.c b/src/ceph.c index 06d57af6..fb215ef9 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -405,6 +405,7 @@ static void compact_ds_name(char *source, char *dest) char *keys[16]; char len_str[3]; char tmp[DATA_MAX_NAME_LEN]; + size_t key_chars_remaining = (DATA_MAX_NAME_LEN-1); int reserved = 0; int offset = 0; memset(tmp, 0, sizeof(tmp)); @@ -431,9 +432,9 @@ static void compact_ds_name(char *source, char *dest) /** concatenate each part of source string **/ for(i = 0; i < keys_num; i++) { - strcat(tmp, keys[i]); + strncat(tmp, keys[i], key_chars_remaining); + key_chars_remaining -= strlen(keys[i]); } - tmp[DATA_MAX_NAME_LEN - 1] = '\0'; /** to coordinate limitation of length of ds name from RRD * we will truncate ds_name * when the its length is more than