Message ID | 20211102100316.20256-1-wangyugui@e16-tech.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: fix XX_flags_to_str() to always end with '\0' | expand |
On 2021/11/2 18:03, Wang Yugui wrote: > [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. > > Signed-off-by: Wang Yugui (wangyugui@e16-tech.com) Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > kernel-shared/print-tree.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c > index 39655590..1b6e4a02 100644 > --- a/kernel-shared/print-tree.c > +++ b/kernel-shared/print-tree.c > @@ -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"); >
On Tue, Nov 02, 2021 at 06:03:16PM +0800, Wang Yugui wrote: > [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. > > Signed-off-by: Wang Yugui (wangyugui@e16-tech.com) Added to devel, thanks.
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 39655590..1b6e4a02 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -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");
[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. Signed-off-by: Wang Yugui (wangyugui@e16-tech.com) --- kernel-shared/print-tree.c | 3 +++ 1 file changed, 3 insertions(+)