* [PATCH] fs: fat: inode: Replace sprintf() with scnprintf()
@ 2026-06-03 14:52 Maxwell Doose
2026-06-04 6:23 ` OGAWA Hirofumi
0 siblings, 1 reply; 2+ messages in thread
From: Maxwell Doose @ 2026-06-03 14:52 UTC (permalink / raw)
To: OGAWA Hirofumi, open list; +Cc: Maxwell Doose
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs: fat: inode: Replace sprintf() with scnprintf()
2026-06-03 14:52 [PATCH] fs: fat: inode: Replace sprintf() with scnprintf() Maxwell Doose
@ 2026-06-04 6:23 ` OGAWA Hirofumi
0 siblings, 0 replies; 2+ messages in thread
From: OGAWA Hirofumi @ 2026-06-04 6:23 UTC (permalink / raw)
To: Andrew Morton; +Cc: Maxwell Doose, linux-fsdevel, open list
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-04 6:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 14:52 [PATCH] fs: fat: inode: Replace sprintf() with scnprintf() Maxwell Doose
2026-06-04 6:23 ` OGAWA Hirofumi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox