Skip to content

Commit 3bdc6ca

Browse files
tobluxtyhicks
authored andcommitted
ecryptfs: Replace strcpy with strscpy in ecryptfs_set_default_crypt_stat_vals
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 [1] Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Tyler Hicks <code@tyhicks.com>
1 parent 5c31c9b commit 3bdc6ca

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/ecryptfs/crypto.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/file.h>
2121
#include <linux/scatterlist.h>
2222
#include <linux/slab.h>
23+
#include <linux/string.h>
2324
#include <linux/unaligned.h>
2425
#include <linux/kernel.h>
2526
#include <linux/xattr.h>
@@ -645,7 +646,7 @@ static void ecryptfs_set_default_crypt_stat_vals(
645646
ecryptfs_copy_mount_wide_flags_to_inode_flags(crypt_stat,
646647
mount_crypt_stat);
647648
ecryptfs_set_default_sizes(crypt_stat);
648-
strcpy(crypt_stat->cipher, ECRYPTFS_DEFAULT_CIPHER);
649+
strscpy(crypt_stat->cipher, ECRYPTFS_DEFAULT_CIPHER);
649650
crypt_stat->key_size = ECRYPTFS_DEFAULT_KEY_BYTES;
650651
crypt_stat->flags &= ~(ECRYPTFS_KEY_VALID);
651652
crypt_stat->file_version = ECRYPTFS_FILE_VERSION;

0 commit comments

Comments
 (0)