The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Maxwell Doose <m32285159@gmail.com>,
	linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] fs: fat: inode: Replace sprintf() with scnprintf()
Date: Thu, 04 Jun 2026 15:23:06 +0900	[thread overview]
Message-ID: <871pemx1rp.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20260603145222.59012-1-m32285159@gmail.com>

Maxwell Doose <m32285159@gmail.com> writes:

> The kernel documentation notes that sprintf() is deprecated and unsafe.
> Replace it with the more preferred scnprintf() to help with hardening.
>
> Signed-off-by: Maxwell Doose <m32285159@gmail.com>

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

> ---
>  Test compiled only, as the only functional change is the addition of
>  bounds checking.
>
>  fs/fat/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 28f78df086ef..b032bbc6855c 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -1786,7 +1786,7 @@ int fat_fill_super(struct super_block *sb, struct fs_context *fc,
>  	 */
>  
>  	error = -EINVAL;
> -	sprintf(buf, "cp%d", sbi->options.codepage);
> +	scnprintf(buf, sizeof(buf), "cp%d", sbi->options.codepage);
>  	sbi->nls_disk = load_nls(buf);
>  	if (!sbi->nls_disk) {
>  		fat_msg(sb, KERN_ERR, "codepage %s not found", buf);

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

      reply	other threads:[~2026-06-04  6:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 14:52 [PATCH] fs: fat: inode: Replace sprintf() with scnprintf() Maxwell Doose
2026-06-04  6:23 ` OGAWA Hirofumi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871pemx1rp.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m32285159@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox