f2fs: replace deprecated strcpy with strscpy
authorDaniel Yang <danielyangkang@gmail.com>
Mon, 18 Nov 2024 07:01:40 +0000 (23:01 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 21 Nov 2024 16:12:29 +0000 (16:12 +0000)
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>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c

index 35c4394..7bcd647 100644 (file)
@@ -1172,7 +1172,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;
@@ -1201,7 +1205,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;