fsck.f2fs: do not print content beyond sb->version
PATCH 1/1 fsck.f2fs: do not print content beyond sb->version
Currently, versions in f2fs_configuration have one more byte than those in sb, so versions in sb may not end with '\0', and then print_raw_sb_info() will print something beyond sb->version.
--- fsck/mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fsck/mount.c +4 -1
@@ -341,7 +341,10 @@ void print_raw_sb_info(struct f2fs_super_block *sb)DISP_u32 (sb, node_ino);DISP_u32 (sb, meta_ino);DISP_u32 (sb, cp_payload); -DISP ("%s" , sb, version); +if (sb->version[255 ] !='\0' ) +DISP ("%-.256s" , sb, version); +else +DISP ("%s" , sb, version);printf ("\n" ); }
Signature · 6 lines
2.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Actually, I prefer to fix this bug by unifying the length of versions in f2fs_configuration and f2fs_super_block :)
Reference: https://sourceforge.net/p/linux-f2fs/mailman/message/35398537/
Thanks
Quoted 16 lines · Junling Zheng
Currently, versions in
f2fs_configurationhave one more byte than those in sb, so versions in sb may not end with '\0', and thenprint_raw_sb_info()will print something beyondsb->version.Signed-off-by Junling Zheng <[email protected]>--- fsck/mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fsck/mount.c +0
-0@@ -341,7 +341,10 @@ void print_raw_sb_info(struct f2fs_super_block *sb)DISP_u32 (sb, node_ino);
fsck/mount.c void print_raw_sb_info(struct f2fs_super_block *sb) · line 350
Quoted 10 lines
fsck/mount.c +4
-1DISP_u32 (sb, meta_ino);DISP_u32 (sb, cp_payload); -DISP ("%s" , sb, version); +if (sb->version[255 ] !='\0' ) +DISP ("%-.256s" , sb, version); +else +DISP ("%s" , sb, version);printf ("\n" ); }
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 14 lines · Junling Zheng
Currently, versions in
f2fs_configurationhave one more byte than those in sb, so versions in sb may not end with '\0', and thenprint_raw_sb_info()will print something beyondsb->version.Signed-off-by Junling Zheng <[email protected]>--- fsck/mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fsck/mount.c +0
-0
fsck/mount.c void print_raw_sb_info(struct f2fs_super_block *sb) · line 347
Quoted 8 lines
fsck/mount.c +4
-1@@ -341,7 +341,10 @@ void print_raw_sb_info(struct f2fs_super_block *sb)DISP_u32 (sb, node_ino);DISP_u32 (sb, meta_ino);DISP_u32 (sb, cp_payload); -DISP ("%s" , sb, version); +if (sb->version[255 ] !='\0' ) +DISP ("%-.256s" , sb, version); +else +DISP ("%s" , sb, version);
IMO, DISP("%-.256s", sb, version) is enough.
Thanks,
fsck/mount.c void print_raw_sb_info(struct f2fs_super_block *sb) · line 350
Quoted 4 lines
fsck/mount.c +0
-0printf ("\n" ); }
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 10 lines · Chao Yu
Quoted 9 lines · Junling Zheng
Currently, versions in
f2fs_configurationhave one more byte than those in sb, so versions in sb may not end with '\0', and thenprint_raw_sb_info()will print something beyondsb->version.Signed-off-by Junling Zheng <[email protected]>--- fsck/mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 16 lines
fsck/mount.c void print_raw_sb_info(struct f2fs_super_block *sb) · line 347
Quoted 13 lines
fsck/mount.c +4
-1@@ -341,7 +341,10 @@ void print_raw_sb_info(struct f2fs_super_block *sb)DISP_u32 (sb, node_ino);DISP_u32 (sb, meta_ino);DISP_u32 (sb, cp_payload); -DISP ("%s" , sb, version); +if (sb->version[255 ] !='\0' ) +DISP ("%-.256s" , sb, version); +else +DISP ("%s" , sb, version);IMO,
DISP("%-.256s", sb, version)is enough.
Yeah, it works :)
Thanks,
Quoted 10 lines
Thanks,
fsck/mount.c void print_raw_sb_info(struct f2fs_super_block *sb) · line 350
Quoted 4 lines
fsck/mount.c +0
-0printf ("\n" ); }.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH v2 1/1 fsck.f2fs: do not print content beyond sb->version
In reply to Junling ZhengCurrently, versions in f2fs_configuration have one more byte than those in sb, so versions in sb may not end with '\0', and then print_raw_sb_info() will print something beyond sb->version.
--- fsck/mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/mount.c +1 -1
@@ -341,7 +341,7 @@ void print_raw_sb_info(struct f2fs_super_block *sb)DISP_u32 (sb, node_ino);DISP_u32 (sb, meta_ino);DISP_u32 (sb, cp_payload); -DISP ("%s" , sb, version); +DISP ("%-.256s" , sb, version);printf ("\n" ); }
Signature · 6 lines
2.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 5 lines · Junling Zheng
Currently, versions in
f2fs_configurationhave one more byte than those in sb, so versions in sb may not end with '\0', and thenprint_raw_sb_info()will print something beyondsb->version.Signed-off-by Junling Zheng <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot