Skip to content

Commit

Permalink
cleanup(engine): strncpy -> strlcpy
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Oct 19, 2023
1 parent 39aa8fe commit 3ff2bb5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions userspace/falco/stats_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3ff2bb5

Please sign in to comment.