lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f8437991-2688-33f8-3843-4e5ffe72a308@linux.intel.com>
Date: Thu, 26 Jun 2025 18:50:07 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Shravan Kumar Ramani <shravankr@...dia.com>
cc: Vadim Pasternak <vadimp@...dia.com>, 
    David Thompson <davthompson@...dia.com>, 
    platform-driver-x86@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>, 
    David Thompson <davthomspson@...dia.com>
Subject: Re: [PATCH v2 1/2] platform/mellanox: mlxbf-pmc: Replace strcmp with
 strncmp

On Wed, 18 Jun 2025, Shravan Kumar Ramani wrote:

> Since the input string passed via the command line appends a newline char,
> comparison using strcmp is not correct. Use the string length of the
> event_list entries to match the string using strncmp instead.

Please include () after any function name (don't forget those in the 
shortlog).

> Fixes: 1a218d312e65 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
> Signed-off-by: Shravan Kumar Ramani <shravankr@...dia.com>
> Reviewed-by: David Thompson <davthomspson@...dia.com>
> ---
>  drivers/platform/mellanox/mlxbf-pmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
> index 900069eb186e..366c0cba447f 100644
> --- a/drivers/platform/mellanox/mlxbf-pmc.c
> +++ b/drivers/platform/mellanox/mlxbf-pmc.c
> @@ -1215,7 +1215,7 @@ static int mlxbf_pmc_get_event_num(const char *blk, const char *evt)
>  		return -EINVAL;
>  
>  	for (i = 0; i < size; ++i) {
> -		if (!strcmp(evt, events[i].evt_name))
> +		if (!strncmp(evt, events[i].evt_name, strlen(events[i].evt_name)))

So if there's extra garbage behind the input, it will also match 
spuriously? So store the len and reduce it if there's a trailing newline 
to make it more robust?

>  			return events[i].evt_num;
>  	}
>  
> 

-- 
 i.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ