All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsck.f2fs: do not print content beyond sb->version
@ 2018-06-06 14:39 Junling Zheng
  2018-06-06 14:45 ` Junling Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Junling Zheng @ 2018-06-06 14:39 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

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 <zhengjunling@huawei.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] fsck.f2fs: do not print content beyond sb->version
  2018-06-06 14:39 [PATCH] fsck.f2fs: do not print content beyond sb->version Junling Zheng
@ 2018-06-06 14:45 ` Junling Zheng
  2018-06-07 10:53 ` Chao Yu
  2018-06-08  5:11 ` [PATCH v2] " Junling Zheng
  2 siblings, 0 replies; 6+ messages in thread
From: Junling Zheng @ 2018-06-06 14:45 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

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 <zhengjunling@huawei.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] fsck.f2fs: do not print content beyond sb->version
  2018-06-06 14:39 [PATCH] fsck.f2fs: do not print content beyond sb->version Junling Zheng
  2018-06-06 14:45 ` Junling Zheng
@ 2018-06-07 10:53 ` Chao Yu
  2018-06-08  5:13   ` Junling Zheng
  2018-06-08  5:11 ` [PATCH v2] " Junling Zheng
  2 siblings, 1 reply; 6+ messages in thread
From: Chao Yu @ 2018-06-07 10:53 UTC (permalink / raw)
  To: Junling Zheng, jaegeuk; +Cc: miaoxie, linux-f2fs-devel

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 <zhengjunling@huawei.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] fsck.f2fs: do not print content beyond sb->version
  2018-06-06 14:39 [PATCH] fsck.f2fs: do not print content beyond sb->version Junling Zheng
  2018-06-06 14:45 ` Junling Zheng
  2018-06-07 10:53 ` Chao Yu
@ 2018-06-08  5:11 ` Junling Zheng
  2018-06-08  9:39   ` Chao Yu
  2 siblings, 1 reply; 6+ messages in thread
From: Junling Zheng @ 2018-06-08  5:11 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

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 <zhengjunling@huawei.com>
---
 fsck/mount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 0a30adb..66b4a5d 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -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");
 }
 
-- 
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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] fsck.f2fs: do not print content beyond sb->version
  2018-06-07 10:53 ` Chao Yu
@ 2018-06-08  5:13   ` Junling Zheng
  0 siblings, 0 replies; 6+ messages in thread
From: Junling Zheng @ 2018-06-08  5:13 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: miaoxie, linux-f2fs-devel

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 <zhengjunling@huawei.com>
>> ---
>>  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] fsck.f2fs: do not print content beyond sb->version
  2018-06-08  5:11 ` [PATCH v2] " Junling Zheng
@ 2018-06-08  9:39   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2018-06-08  9:39 UTC (permalink / raw)
  To: Junling Zheng, jaegeuk; +Cc: miaoxie, linux-f2fs-devel

On 2018/6/8 13:11, 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 <zhengjunling@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-08  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 14:39 [PATCH] fsck.f2fs: do not print content beyond sb->version Junling Zheng
2018-06-06 14:45 ` Junling Zheng
2018-06-07 10:53 ` Chao Yu
2018-06-08  5:13   ` Junling Zheng
2018-06-08  5:11 ` [PATCH v2] " Junling Zheng
2018-06-08  9:39   ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.