btrfs-progs: fix XX_flags_to_str() to always end with '\0'
PATCH 1/1 btrfs-progs: fix XX_flags_to_str() to always end with '\0'
[BUG]
We noticed 'btrfs check' output something like
leaf 30408704 flags 0x0(P1逅?) backref revision 1
but we expected
leaf 30408704 flags 0x0() backref revision 1
[CAUSE]
some XX_flags_to_str() failed to make sure the result string always end with '\0' in some case.
[FIX]
add 'ret[0] = 0;' at the begining.
--- kernel-shared/print-tree.c | 3 +++ 1 file changed, 3 insertions(+)
kernel-shared/print-tree.c +3 -0
@@ -210,6 +210,7 @@ static void bg_flags_to_str(u64 flags, char *ret)/* Caller should ensure sizeof(*ret)>= 26 "OFF|SCANNING|INCONSISTENT" */ static void qgroup_flags_to_str (u64 flags,char *ret) { + ret[0 ] ='\0' ;if (flags &BTRFS_QGROUP_STATUS_FLAG_ON )strcpy (ret,"ON" );else
@@ -417,6 +418,7 @@ static void extent_flags_to_str(u64 flags, char *ret) {int empty =1 ; + ret[0 ] ='\0' ;if (flags &BTRFS_EXTENT_FLAG_DATA ) { empty =0 ;strcpy (ret,"DATA" );
@@ -1201,6 +1203,7 @@ static void header_flags_to_str(u64 flags, char *ret) {int empty =1 ; + ret[0 ] ='\0' ;if (flags &BTRFS_HEADER_FLAG_WRITTEN ) { empty =0 ;strcpy (ret,"WRITTEN" );
Signature · 1 line
2.32.0
Quoted 6 lines · Wang Yugui
[BUG]
We noticed 'btrfs check' output something like
leaf 30408704 flags 0x0(P1逅?) backref revision 1
but we expected
leaf 30408704 flags 0x0() backref revision 1
Quoted 8 lines
[CAUSE]
someXX_flags_to_str()failed to make sure the result string always end with '\0' in some case.[FIX]
add 'ret[0] = 0;' at the begining.Signed-off-by Wang Yugui ([email protected])
Thanks,
Qu
Quoted 33 lines
--- kernel-shared/print-tree.c | 3 +++ 1 file changed, 3 insertions(+)kernel-shared/print-tree.c +3
-0@@ -210,6 +210,7 @@ static void bg_flags_to_str(u64 flags, char *ret)/* Caller should ensure sizeof(*ret)>= 26 "OFF|SCANNING|INCONSISTENT" */ static void qgroup_flags_to_str (u64 flags,char *ret) { + ret[0 ] ='\0' ;if (flags &BTRFS_QGROUP_STATUS_FLAG_ON )strcpy (ret,"ON" );else @@ -417,6 +418,7 @@ static void extent_flags_to_str(u64 flags, char *ret) {int empty =1 ; + ret[0 ] ='\0' ;if (flags &BTRFS_EXTENT_FLAG_DATA ) { empty =0 ;strcpy (ret,"DATA" );@@ -1201,6 +1203,7 @@ static void header_flags_to_str(u64 flags, char *ret) {int empty =1 ; + ret[0 ] ='\0' ;if (flags &BTRFS_HEADER_FLAG_WRITTEN ) { empty =0 ;strcpy (ret,"WRITTEN" );
Quoted 6 lines · Wang Yugui
[BUG]
We noticed 'btrfs check' output something like
leaf 30408704 flags 0x0(P1逅?) backref revision 1
but we expected
leaf 30408704 flags 0x0() backref revision 1
Quoted 8 lines
[CAUSE]
someXX_flags_to_str()failed to make sure the result string always end with '\0' in some case.[FIX]
add 'ret[0] = 0;' at the begining.Signed-off-by Wang Yugui ([email protected])
Added to devel, thanks.