Re: [f2fs-dev] [PATCH] fsck.f2fs: do not print content beyond sb->version

2018-06-07 Thread Junling Zheng
On 2018/6/7 18:53, Chao Yu wrote:
> On 2018/6/6 22:39, Junling Zheng wrote:
>> 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.
>>
>> Signed-off-by: Junling Zheng 
>> ---
>>  fsck/mount.c | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fsck/mount.c b/fsck/mount.c
>> index 0a30adb..9def919 100644
>> --- a/fsck/mount.c
>> +++ b/fsck/mount.c
>> @@ -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,

> Thanks,
> 
>>  printf("\n");
>>  }
>>  
>>
> 
> 
> .
> 



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] fsck.f2fs: do not print content beyond sb->version

2018-06-07 Thread Chao Yu
On 2018/6/6 22:39, Junling Zheng wrote:
> 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.
> 
> Signed-off-by: Junling Zheng 
> ---
>  fsck/mount.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index 0a30adb..9def919 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -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,

>   printf("\n");
>  }
>  
> 


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] fsck.f2fs: do not print content beyond sb->version

2018-06-06 Thread Junling Zheng
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

On 2018/6/6 22:39, Junling Zheng wrote:
> 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.
> 
> Signed-off-by: Junling Zheng 
> ---
>  fsck/mount.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index 0a30adb..9def919 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -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");
>  }
>  
> 



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] fsck.f2fs: do not print content beyond sb->version

2018-06-06 Thread Junling Zheng
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.

Signed-off-by: Junling Zheng 
---
 fsck/mount.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 0a30adb..9def919 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -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");
 }
 
-- 
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
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel