From: Maxwell Doose <m32285159@gmail.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
linux-kernel@vger.kernel.org (open list)
Cc: Maxwell Doose <m32285159@gmail.com>
Subject: [PATCH] fs: fat: inode: Replace sprintf() with scnprintf()
Date: Wed, 3 Jun 2026 09:52:21 -0500 [thread overview]
Message-ID: <20260603145222.59012-1-m32285159@gmail.com> (raw)
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>
---
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);
--
2.54.0
next reply other threads:[~2026-06-03 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:52 Maxwell Doose [this message]
2026-06-04 6:23 ` [PATCH] fs: fat: inode: Replace sprintf() with scnprintf() OGAWA Hirofumi
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=20260603145222.59012-1-m32285159@gmail.com \
--to=m32285159@gmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
/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