btrfs-progs: convert: initialize the target fs label

[BUG]
When running some tests, I notice that my debug build of btrfs-convert
is throwing out garbage for target fs label:

  $ ./btrfs-convert  ~/test.img
  btrfs-convert from btrfs-progs v5.17

  Source filesystem:
    Type:           ext2
    Label:
    Blocksize:      4096
    UUID:           29d159a8-cb46-41d3-8089-3c5c65e4afae
  Target filesystem:
    Label:          @pcwU	<<< Garbage here
    Blocksize:      4096
    Nodesize:       16384
    UUID:           682bf5f2-8cb1-4390-b9ac-6883cd87ed39
    Checksum:       crc32c
  ...

[CAUSE]
The fslabel[] array is just not initialized, thus it can contain
garbage.

[FIX]
Initialize fslabel[] array to all zero.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2022-05-13 16:51:10 +08:00 committed by David Sterba
parent 23c6d24668
commit 8765c39c7e

View File

@ -1822,7 +1822,7 @@ int BOX_MAIN(convert)(int argc, char *argv[])
int usage_error = 0;
int progress = 1;
char *file;
char fslabel[BTRFS_LABEL_SIZE];
char fslabel[BTRFS_LABEL_SIZE] = { 0 };
u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
u16 csum_type = BTRFS_CSUM_TYPE_CRC32;
u32 copy_fsid = 0;