mkfs.f2fs: fix a segfault when setting more than 7 devices
PATCH 1/1 mkfs.f2fs: fix a segfault when setting more than 7 devices
[root@localhost f2fs-tools]# mkfs.f2fs -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 /dev/sdb1
kernel: mkfs.f2fs[9047]: segfault at 2b78a60f ip 0000000000401356 sp 00007fffde05c9c0 error 6 in mkfs.f2fs[400000+5000]
Signed-off-by Kinglong Mee <[email protected]>
--- mkfs/f2fs_format_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
mkfs/f2fs_format_main.c +7 -6
@@ -28,7 +28,7 @@ static void mkfs_usage()MSG (0 ,"\nUsage: mkfs.f2fs [options] device [sectors]\n" );MSG (0 ,"[options]:\n" );MSG (0 ," -a heap-based allocation [default:1]\n" ); -MSG (0 ," -c [device path]\n" ); +MSG (0 ," -c [device path] up to 7 devices excepts meta device\n" );MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -e [extension list] e.g. \"mp3,gif,mov\"\n" );MSG (0 ," -l label\n" );
@@ -84,6 +84,11 @@ static void f2fs_parse_options(int argc, char *argv[]) c.heap =atoi (optarg);break ;case 'c' : +if (c.ndevs >=MAX_DEVICES ) { +MSG (0 ,"Error: Too many devices\n" ); +mkfs_usage (); + } +if (strlen (optarg) >MAX_PATH_LEN ) {MSG (0 ,"Error: device path should be less than " "%d characters\n" ,MAX_PATH_LEN );
@@ -135,12 +140,8 @@ static void f2fs_parse_options(int argc, char *argv[])mkfs_usage (); } -/* [0] : META, [1 to MAX_DEVICES + 1] : NODE/DATA */ +/* [0] : META, [1 to MAX_DEVICES - 1] : NODE/DATA */ c.devices[0 ].path =strdup (argv[optind]); -if (c.ndevs >MAX_DEVICES ) { -MSG (0 ,"\tError: Too many devices\n" ); -mkfs_usage (); - }if ((optind +1 ) < argc) {if (c.ndevs >1 ) {
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot