btrfs-progs: qgroup: check null in comparing paths
PATCH 1/1 btrfs-progs: qgroup: check null in comparing paths
This patch fixes a bug that could occur when comparing paths in showing qgroups list. Old code doesn't check it and the bug occur when there is stale qgroup its path is null. This patch checkes whether it is null and return without comparing paths.
Issue: #687
--- cmds/qgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+)
cmds/qgroup.c +8 -0
@@ -486,6 +486,14 @@ static int comp_entry_with_path(struct btrfs_qgroup *entry1,if (ret) goto out; +if (!p1) { + ret = p2 ?1 :0 ; + goto out; + }else if (!p2) { + ret =-1 ; + goto out; + } +while (*p1 && *p2) {if (*p1 != *p2)break ;
Signature · 1 line
2.34.1
Quoted 7 lines · Sidong Yang
This patch fixes a bug that could occur when comparing paths in showing qgroups list. Old code doesn't check it and the bug occur when there is stale qgroup its path is null. This patch checkes whether it is null and return without comparing paths.
Issue: #687
Signed-off-by Sidong Yang <[email protected]>
It's also a good chance to contribute a new patch to add such test case to btrfs-progs.
Feel free to ask for any help on creating such test case.
Thanks,
Qu
Quoted 23 lines
--- cmds/qgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+)cmds/qgroup.c +8
-0@@ -486,6 +486,14 @@ static int comp_entry_with_path(struct btrfs_qgroup *entry1,if (ret) goto out; +if (!p1) { + ret = p2 ?1 :0 ; + goto out; + }else if (!p2) { + ret =-1 ; + goto out; + } +while (*p1 && *p2) {if (*p1 != *p2)break ;
Quoted 7 lines · Sidong Yang
This patch fixes a bug that could occur when comparing paths in showing qgroups list. Old code doesn't check it and the bug occur when there is stale qgroup its path is null. This patch checkes whether it is null and return without comparing paths.
Issue: #687
Signed-off-by Sidong Yang <[email protected]>
Added to devel, thanks. I've also added the test case.