mkfs.f2fs: Fix out-of-bounds read in f2fs_prepare_super_block
PATCH 1/1 mkfs.f2fs: Fix out-of-bounds read in f2fs_prepare_super_block
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 <[email protected]>
--- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/f2fs_format.c +1 -1
@@ -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); }
Signature · 8 lines
2.46.0.rc1.232.g9752f9e123-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel