From ad44939e402554c4a5775c3192614cb474180d28 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 7 Apr 2023 15:38:58 +0200 Subject: [PATCH] CLEANUP: opentracing: remove the last two occurrences of strncat() In flt_ot_sample_to_str() there were two occurrences of strncat() which are used to copy N chars from the source and append a zero. For the sake of definitely getting rid of this nasty function let's replace them by memcpy() instead. It's worth noting that the length test there appeared to be incorrect as it didn't make provisions for the trailing zero, unless the size argument doesn't take it into account (seems unlikely). Nothing was changed regarding this. If the code was good, it still is, otherwise if it was bad it still is. At least this is more obvious now than when using a function that needs n+1 chars to work. --- addons/ot/src/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/ot/src/util.c b/addons/ot/src/util.c index 767685ea9..fd040164d 100644 --- a/addons/ot/src/util.c +++ b/addons/ot/src/util.c @@ -553,8 +553,8 @@ int flt_ot_sample_to_str(const struct sample_data *data, char *value, size_t siz } else if (data->u.str.data > 0) { retval = data->u.str.data; - - (void)strncat(value, data->u.str.area, retval); + memcpy(value, data->u.str.area, retval); + value[retval] = '\0'; } else { /* @@ -615,8 +615,8 @@ int flt_ot_sample_to_str(const struct sample_data *data, char *value, size_t siz FLT_OT_ERR("sample data size too large"); } else { retval = data->u.meth.str.data; - - (void)strncat(value, data->u.meth.str.area, retval); + memcpy(value, data->u.meth.str.area, retval); + value[retval] = '\0'; } } else { -- 2.47.3