From 3ff2bb5c2b306c1f81585e53477e1585695b0dc8 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Thu, 19 Oct 2023 08:07:53 +0000 Subject: [PATCH] cleanup(engine): strncpy -> strlcpy Signed-off-by: Luca Guerra --- userspace/falco/stats_writer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/userspace/falco/stats_writer.cpp b/userspace/falco/stats_writer.cpp index f085d98d9de..aa731794885 100644 --- a/userspace/falco/stats_writer.cpp +++ b/userspace/falco/stats_writer.cpp @@ -27,6 +27,7 @@ limitations under the License. #include "stats_writer.h" #include "logger.h" #include "config_falco.h" +#include "strl.h" // note: ticker_t is an uint16_t, which is enough because we don't care about // overflows here. Threads calling stats_writer::handle() will just @@ -308,7 +309,7 @@ void stats_writer::collector::get_metrics_output_fields_additional( for(uint32_t stat = 0; stat < nstats; stat++) { char metric_name[STATS_NAME_MAX] = "falco."; - strncat(metric_name, utilization[stat].name, sizeof(metric_name) - strlen(metric_name) - 1); + strlcat(metric_name, utilization[stat].name, sizeof(metric_name)); switch(utilization[stat].type) { case STATS_VALUE_TYPE_U64: @@ -384,7 +385,7 @@ void stats_writer::collector::get_metrics_output_fields_additional( // todo: as we expand scap_stats_v2 prefix may be pushed to scap or we may need to expand // functionality here for example if we add userspace syscall counters that should be prefixed w/ `falco.` char metric_name[STATS_NAME_MAX] = "scap."; - strncat(metric_name, stats_v2[stat].name, sizeof(metric_name) - strlen(metric_name) - 1); + strlcat(metric_name, stats_v2[stat].name, sizeof(metric_name)); switch(stats_v2[stat].type) { case STATS_VALUE_TYPE_U64: