parse_options(): replace deprecated strcpy with strscpy
PATCH 1/1 parse_options(): replace deprecated strcpy with strscpy
strcpy is deprecated. Kernel docs recommend replacing strcpy with strscpy. The function strcpy() return value isn't used so there shouldn't be an issue replacing with the safer alternative strscpy.
--- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/super.c +2 -2
@@ -1158,7 +1158,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; } -strcpy (ext[ext_cnt], name); +strscpy (ext[ext_cnt], name);F2FS_OPTION (sbi).compress_ext_cnt++;kfree (name);break ;
@@ -1187,7 +1187,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; } -strcpy (noext[noext_cnt], name); +strscpy (noext[noext_cnt], name);F2FS_OPTION (sbi).nocompress_ext_cnt++;kfree (name);break ;
Signature · 1 line
2.39.5
Chao Yu
maintainerQuoted 3 lines · Daniel Yang
strcpy is deprecated. Kernel docs recommend replacing strcpy with strscpy. The function
strcpy()return value isn't used so there shouldn't be an issue replacing with the safer alternative strscpy.
It's better to add "f2fs: " prefix for commit title.
Quoted 11 lines
Signed-off-by Daniel Yang <[email protected]>--- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1161
Quoted 5 lines
fs/f2fs/super.c +1
-1@@ -1158,7 +1158,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; } -strcpy (ext[ext_cnt], name); +strscpy (ext[ext_cnt], name);
Needs to handle return value of strscpy()?
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1190
Quoted 9 lines
fs/f2fs/super.c +1
-1F2FS_OPTION (sbi).compress_ext_cnt++;kfree (name);break ;@@ -1187,7 +1187,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; } -strcpy (noext[noext_cnt], name); +strscpy (noext[noext_cnt], name);
Ditto,
Thanks,
Quoted 3 lines
fs/f2fs/super.c +0
-0F2FS_OPTION (sbi).nocompress_ext_cnt++;kfree (name);break ;
Quoted 34 lines · Chao Yu
Quoted 3 lines · Daniel Yang
strcpy is deprecated. Kernel docs recommend replacing strcpy with strscpy. The function
strcpy()return value isn't used so there shouldn't be an issue replacing with the safer alternative strscpy.It's better to add "f2fs: " prefix for commit title.
Quoted 11 lines
Signed-off-by Daniel Yang <[email protected]>--- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1161
Quoted 5 lines
fs/f2fs/super.c +1
-1@@ -1158,7 +1158,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; } -strcpy (ext[ext_cnt], name); +strscpy (ext[ext_cnt], name);Needs to handle return value of
strscpy()?Quoted 7 lines
fs/f2fs/super.c +0
-0F2FS_OPTION (sbi).compress_ext_cnt++;kfree (name);break ;@@ -1187,7 +1187,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ; }
Quoted 11 lines
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1190
Quoted 2 lines
fs/f2fs/super.c +1
-1-strcpy (noext[noext_cnt], name); +strscpy (noext[noext_cnt], name);Ditto,
Thanks,
Quoted 3 lines
fs/f2fs/super.c +0
-0F2FS_OPTION (sbi).nocompress_ext_cnt++;kfree (name);break ;
Ok, I've added the changes and sent a v2 of the patch. Lmk if there's any other issues.
- Daniel