[dpdk-dev] [PATCH v4 09/18] net/qede: strncpy length constant and NUL

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Fri May 11 12:43:41 CEST 2018



> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Andy Green
> Sent: Friday, May 11, 2018 2:46 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v4 09/18] net/qede: strncpy length constant and
> NUL
> 
> Signed-off-by: Andy Green <andy at warmcat.com>
> ---
>  drivers/net/qede/base/ecore_int.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/qede/base/ecore_int.c
> b/drivers/net/qede/base/ecore_int.c
> index f43781ba4..d9e22b5ed 100644
> --- a/drivers/net/qede/base/ecore_int.c
> +++ b/drivers/net/qede/base/ecore_int.c
> @@ -6,6 +6,8 @@
>   * See LICENSE.qede_pmd for copyright and licensing details.
>   */
> 
> +#include <rte_string_fns.h>
> +
>  #include "bcm_osal.h"
>  #include "ecore.h"
>  #include "ecore_spq.h"
> @@ -1104,9 +1106,9 @@ static enum _ecore_status_t
> ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
>  							      p_aeu->bit_name,
>  							      num);
>  					else
> -						OSAL_STRNCPY(bit_name,
> -							     p_aeu->bit_name,
> -							     30);
> +						strlcpy(bit_name,
> +							p_aeu->bit_name,
> +							sizeof(bit_name));
> 
>  					/* We now need to pass bitmask in its
>  					 * correct position.

I'd say it should be better to change OSAL_STRNCPY to OSAL_STRLCPY and
modify the macro to use strlcpy, so we avoid further uses of that strlcpy.

However, this modifies base driver code, so it is up to the maintainers to make that decision.
(CC'ing maintainers here).

Also, missing fixes line and CC stable.

Fixes: 8427c6647964 ("net/qede/base: add attention formatting string")
Cc: stable at dpdk.org


More information about the dev mailing list