diff mbox series

[f2fs-dev,v3] f2fs: replace deprecated strcpy with strscpy

Message ID 20241118070141.3474-1-danielyangkang@gmail.com (mailing list archive)
State New
Headers show
Series [f2fs-dev,v3] f2fs: replace deprecated strcpy with strscpy | expand

Commit Message

Daniel Yang Nov. 18, 2024, 7:01 a.m. UTC
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.

Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
---
v2 -> v3: store strscpy result in ret and return ret if error
v1 -> v2: handle strscpy errors, changed prefix to f2fs
 fs/f2fs/super.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Chao Yu Nov. 18, 2024, 8:14 a.m. UTC | #1
On 2024/11/18 15:01, Daniel Yang wrote:
> 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.
> 
> Signed-off-by: Daniel Yang <danielyangkang@gmail.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 87ab5696b..3eb754547 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1158,7 +1158,11 @@  static int parse_options(struct super_block *sb, char *options, bool is_remount)
 				break;
 			}
 
-			strcpy(ext[ext_cnt], name);
+			ret = strscpy(ext[ext_cnt], name);
+			if (ret < 0) {
+				kfree(name);
+				return ret;
+			}
 			F2FS_OPTION(sbi).compress_ext_cnt++;
 			kfree(name);
 			break;
@@ -1187,7 +1191,11 @@  static int parse_options(struct super_block *sb, char *options, bool is_remount)
 				break;
 			}
 
-			strcpy(noext[noext_cnt], name);
+			ret = strscpy(noext[noext_cnt], name);
+			if (ret < 0) {
+				kfree(name);
+				return ret;
+			}
 			F2FS_OPTION(sbi).nocompress_ext_cnt++;
 			kfree(name);
 			break;