The path field in c.devices[i] is a pointer and is normally filled in using strdup. This makes it invalid to copy MAX_PATH_LEN bytes from it because the string may be shorter than that. Therefore, fix the code to use strncpy to copy the string instead.
Signed-off-by: Peter Collingbourne <p...@google.com> --- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index c9d335a..b053685 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -316,7 +316,7 @@ static int f2fs_prepare_super_block(void) c.blks_per_seg - 1; } if (c.ndevs > 1) { - memcpy(sb->devs[i].path, c.devices[i].path, MAX_PATH_LEN); + strncpy((char *)sb->devs[i].path, c.devices[i].path, MAX_PATH_LEN); sb->devs[i].total_segments = cpu_to_le32(c.devices[i].total_segments); } -- 2.46.0.rc1.232.g9752f9e123-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel