|SUCCESS| pw159216 [PATCH v5 05/17] latencystats: add check for string overflow

0-day Robot robot at bytheb.org
Tue Dec 16 17:12:07 CET 2025


Test-Label: 0day Robot - Claude SONNET
Test-Status: SUCCESS
http://dpdk.org/patch/159216

_AI Review Comments Available_

Git SHA: 20251207191242.165619-6-stephen at networkplumber.org
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: latencystats: add check for string overflow

This patch adds a check to detect if latency statistic names are too
long to fit in the metric name buffer, logging a warning if truncation
occurs.

> diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
> index f61d5a273f..0861d00c6b 100644
> --- a/lib/latencystats/rte_latencystats.c
> +++ b/lib/latencystats/rte_latencystats.c
> @@ -405,9 +405,12 @@ rte_latencystats_get_names(struct rte_metric_name *names, uint16_t size)
>  	if (names == NULL || size < NUM_LATENCY_STATS)
>  		return NUM_LATENCY_STATS;
>  
> -	for (i = 0; i < NUM_LATENCY_STATS; i++)
> -		strlcpy(names[i].name, lat_stats_strings[i].name,
> -			sizeof(names[i].name));
> +	for (i = 0; i < NUM_LATENCY_STATS; i++) {
> +		if (strlcpy(names[i].name, lat_stats_strings[i].name, sizeof(names[0].name))
> +		    >= sizeof(names[0].name))
> +			LATENCY_STATS_LOG(NOTICE, "Latency metric '%s' too long",
> +					  lat_stats_strings[i].name);
> +	}

Why does this code use sizeof(names[0].name) instead of 
sizeof(names[i].name)? The logic accesses names[i] but sizes using 
names[0]. Does the array contain differently sized name fields?

The coding style guidelines indicate that wrapped function arguments 
should be aligned. Can the strlcpy call follow DPDK alignment rules?

>  
>  	return NUM_LATENCY_STATS;
>  }


More information about the test-report mailing list