]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ecryptfs: Replace strcpy with strscpy in ecryptfs_set_default_crypt_stat_vals
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 13 Dec 2025 11:04:50 +0000 (12:04 +0100)
committerTyler Hicks <code@tyhicks.com>
Tue, 23 Dec 2025 21:23:23 +0000 (15:23 -0600)
strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. Replace
it with the safer strscpy().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Tyler Hicks <code@tyhicks.com>
fs/ecryptfs/crypto.c

index b80f60863b5a8f13c6be0e0e438c76c48aae42fd..c84c7c3de4d956a4f2fbee351aef16ae1a9870aa 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/file.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/unaligned.h>
 #include <linux/kernel.h>
 #include <linux/xattr.h>
@@ -645,7 +646,7 @@ static void ecryptfs_set_default_crypt_stat_vals(
        ecryptfs_copy_mount_wide_flags_to_inode_flags(crypt_stat,
                                                      mount_crypt_stat);
        ecryptfs_set_default_sizes(crypt_stat);
-       strcpy(crypt_stat->cipher, ECRYPTFS_DEFAULT_CIPHER);
+       strscpy(crypt_stat->cipher, ECRYPTFS_DEFAULT_CIPHER);
        crypt_stat->key_size = ECRYPTFS_DEFAULT_KEY_BYTES;
        crypt_stat->flags &= ~(ECRYPTFS_KEY_VALID);
        crypt_stat->file_version = ECRYPTFS_FILE_VERSION;