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] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2pyCA/tRunNVRQt@kroah.com>
Date:   Tue, 8 Nov 2022 16:13:12 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Deepak R Varma <drv@...lo.com>
Cc:     outreachy@...ts.linux.dev, Sven Van Asbroeck <TheSven73@...il.com>,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: fieldbus: convert snprintf to scnprintf

On Wed, Nov 02, 2022 at 11:55:52PM +0530, Deepak R Varma wrote:
> It is recommended to use scnprintf instead of snprintf to accurately
> return the size of the encoded data. Following article [1] has details
> on the reason for this kernel level migration. This issue was identified
> using coccicheck.
> 
> [1] https://lwn.net/Articles/69419/
> 
> Signed-off-by: Deepak R Varma <drv@...lo.com>
> ---
>  drivers/staging/fieldbus/dev_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
> index 5aab734606ea..d51f2b02d5e6 100644
> --- a/drivers/staging/fieldbus/dev_core.c
> +++ b/drivers/staging/fieldbus/dev_core.c
> @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
>  	 * card_name was provided by child driver, could potentially be long.
>  	 * protect against buffer overrun.
>  	 */
> -	return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
> +	return scnprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);

No, neither of these are correct.

Please use sysfs_emit() for sysfs show callbacks.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ