]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: fat: inode: replace sprintf() with scnprintf()
authorMaxwell Doose <m32285159@gmail.com>
Wed, 3 Jun 2026 14:52:21 +0000 (09:52 -0500)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 11 Jun 2026 18:42:20 +0000 (11:42 -0700)
The kernel documentation notes that sprintf() is deprecated and unsafe.
Replace it with the more preferred scnprintf() to help with hardening.

Link: https://lore.kernel.org/20260603145222.59012-1-m32285159@gmail.com
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/fat/inode.c

index 28f78df086efcc082570dd2d92d1ff0c30825047..b032bbc6855cb2bf23f1f2f3cc5d5e4a40f51fba 100644 (file)
@@ -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);