From 6f0fb094a2c7e5bea41c5914799e06d7025f5e2b Mon Sep 17 00:00:00 2001 From: daryder Date: Mon, 3 Nov 2014 15:55:15 -0500 Subject: [PATCH] Change strcat to strncat --- src/ceph.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.30.2