From: Maxwell Doose Date: Wed, 3 Jun 2026 14:52:21 +0000 (-0500) Subject: fs: fat: inode: replace sprintf() with scnprintf() X-Git-Tag: v7.2-rc1~77^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae636b5463d9957fadba71e83e7cfc157416974;p=thirdparty%2Fkernel%2Flinux.git fs: fat: inode: replace sprintf() with scnprintf() 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 Acked-by: OGAWA Hirofumi Signed-off-by: Andrew Morton --- diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 28f78df086efc..b032bbc6855cb 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);