Skip to contentSkip to conversation

ecryptfs_parse_options(): Replace strcpy with strscpy

PATCH New Daniel Yang 1 participant 1 message Nov 6, 2024 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ecryptfs_parse_options(): Replace strcpy with strscpy

The function strcpy is deprecated. strscpy is recommended to replace strcpy. Instances of strcpy in ecryptfs_parse_options() don't require strcpy return value so the different methods of detecting truncation shouldn't be an issue here.

---
 fs/ecryptfs/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ecryptfs/main.c +2 -2
index 577c56302..d0b8ce70c 100644
@@ -379,12 +379,12 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options,
 		int cipher_name_len = strlen(ECRYPTFS_DEFAULT_CIPHER);
 
 		BUG_ON(cipher_name_len > ECRYPTFS_MAX_CIPHER_NAME_SIZE);
-		strcpy(mount_crypt_stat->global_default_cipher_name,
+		strscpy(mount_crypt_stat->global_default_cipher_name,
 		       ECRYPTFS_DEFAULT_CIPHER);
 	}
 	if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)
 	    && !fn_cipher_name_set)
-		strcpy(mount_crypt_stat->global_default_fn_cipher_name,
+		strscpy(mount_crypt_stat->global_default_fn_cipher_name,
 		       mount_crypt_stat->global_default_cipher_name);
 	if (!cipher_key_bytes_set)
 		mount_crypt_stat->global_default_cipher_key_size = 0;
Signature · 1 line
2.39.5