[dpdk-dev,v4,12/18] net/sfc: solve strncpy size and NUL
Checks
Commit Message
Signed-off-by: Andy Green <andy@warmcat.com>
---
drivers/net/sfc/sfc_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 05/11/2018 04:46 AM, Andy Green wrote:
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
> drivers/net/sfc/sfc_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
> index ef5e9ecb2..a8c0f8e19 100644
> --- a/drivers/net/sfc/sfc_ethdev.c
> +++ b/drivers/net/sfc/sfc_ethdev.c
> @@ -664,7 +664,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev,
> for (i = 0; i < EFX_MAC_NSTATS; ++i) {
> if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
> if (xstats_names != NULL && nstats < xstats_count)
> - strncpy(xstats_names[nstats].name,
> + strlcpy(xstats_names[nstats].name,
> efx_mac_stat_name(sa->nic, i),
> sizeof(xstats_names[0].name));
> nstats++;
>
I'd suggest:
net/sfc: make sure that copied stats name is NUL-terminated
Acked-by: Andrew Rybchenko <arybchenko@oktetlabs.ru>
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green
> Sent: Friday, May 11, 2018 2:46 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v4 12/18] net/sfc: solve strncpy size and NUL
>
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
> drivers/net/sfc/sfc_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index
> ef5e9ecb2..a8c0f8e19 100644
> --- a/drivers/net/sfc/sfc_ethdev.c
> +++ b/drivers/net/sfc/sfc_ethdev.c
> @@ -664,7 +664,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev,
> for (i = 0; i < EFX_MAC_NSTATS; ++i) {
> if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
> if (xstats_names != NULL && nstats < xstats_count)
> - strncpy(xstats_names[nstats].name,
> + strlcpy(xstats_names[nstats].name,
> efx_mac_stat_name(sa->nic, i),
> sizeof(xstats_names[0].name));
> nstats++;
I'd say this patch could be squashed with the previous one, as they are solving the same issue
in the same file.
It also needs an extra fixes line (so the final patch would have two fixes lines) and CC stable too.
Fixes: 7b9891769f4b ("net/sfc: support extended statistics")
Cc: stable@dpdk.org
On 05/11/2018 06:55 PM, De Lara Guarch, Pablo wrote:
>
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green
>> Sent: Friday, May 11, 2018 2:46 AM
>> To: dev@dpdk.org
>> Subject: [dpdk-dev] [PATCH v4 12/18] net/sfc: solve strncpy size and NUL
>>
>> Signed-off-by: Andy Green <andy@warmcat.com>
>> ---
>> drivers/net/sfc/sfc_ethdev.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index
>> ef5e9ecb2..a8c0f8e19 100644
>> --- a/drivers/net/sfc/sfc_ethdev.c
>> +++ b/drivers/net/sfc/sfc_ethdev.c
>> @@ -664,7 +664,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev,
>> for (i = 0; i < EFX_MAC_NSTATS; ++i) {
>> if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
>> if (xstats_names != NULL && nstats < xstats_count)
>> - strncpy(xstats_names[nstats].name,
>> + strlcpy(xstats_names[nstats].name,
>> efx_mac_stat_name(sa->nic, i),
>> sizeof(xstats_names[0].name));
>> nstats++;
>
> I'd say this patch could be squashed with the previous one, as they are solving the same issue
> in the same file.
> It also needs an extra fixes line (so the final patch would have two fixes lines) and CC stable too.
OK it's adapted accordingly.
-Andy
> Fixes: 7b9891769f4b ("net/sfc: support extended statistics")
> Cc: stable@dpdk.org
>
@@ -664,7 +664,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev,
for (i = 0; i < EFX_MAC_NSTATS; ++i) {
if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
if (xstats_names != NULL && nstats < xstats_count)
- strncpy(xstats_names[nstats].name,
+ strlcpy(xstats_names[nstats].name,
efx_mac_stat_name(sa->nic, i),
sizeof(xstats_names[0].name));
nstats++;