On 2016/10/1 0:25, Jaegeuk Kim wrote:
> On Thu, Sep 29, 2016 at 06:38:37PM +0800, Junling Zheng wrote:
>> Currently, versions in f2fs_configuration have one more byte, so versions
>> in f2fs_super_block may not end with '\0', which will cause errors while
>> printing it in print_raw_sb_info(). Unify the length of versions to fix it.
>
> This is to handle non-zero terminated version characters in f2fs_super_block.
> What is your point?
>
> Thanks,
>
If version characters are non-zero terminated in f2fs_super_block, it will get
incorrect results while printing it in print_raw_sb_info():
...
DISP("%s", sb, version);
...
Thanks,
Junling
>>
>> Signed-off-by: Junling Zheng <[email protected]>
>> ---
>> include/f2fs_fs.h | 6 +++---
>> lib/libf2fs.c | 4 ++--
>> 2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
>> index 1345e2d..e666076 100644
>> --- a/include/f2fs_fs.h
>> +++ b/include/f2fs_fs.h
>> @@ -270,9 +270,9 @@ struct f2fs_configuration {
>> u_int64_t target_sectors;
>> u_int32_t sectors_per_blk;
>> u_int32_t blks_per_seg;
>> - __u8 init_version[VERSION_LEN + 1];
>> - __u8 sb_version[VERSION_LEN + 1];
>> - __u8 version[VERSION_LEN + 1];
>> + __u8 init_version[VERSION_LEN];
>> + __u8 sb_version[VERSION_LEN];
>> + __u8 version[VERSION_LEN];
>> char *vol_label;
>> int heap;
>> int32_t fd, kd;
>> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
>> index 706cc34..0a9436b 100644
>> --- a/lib/libf2fs.c
>> +++ b/lib/libf2fs.c
>> @@ -570,11 +570,11 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
>> void get_kernel_version(__u8 *version)
>> {
>> int i;
>> - for (i = 0; i < VERSION_LEN; i++) {
>> + for (i = 0; i < VERSION_LEN - 1; i++) {
>> if (version[i] == '\n')
>> break;
>> }
>> - memset(version + i, 0, VERSION_LEN + 1 - i);
>> + memset(version + i, 0, VERSION_LEN - i);
>> }
>>
>> int f2fs_get_device_info(struct f2fs_configuration *c)
>> --
>> 2.7.4
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
> .
>
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel