Message ID | 20231008091717.27049-1-realwakka@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: qgroup: check null in comparing paths | expand |
On 2023/10/8 19:47, Sidong Yang wrote: > 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 <realwakka@gmail.com> Reviewed-by: Qu Wenruo <wqu@suse.com> 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 > --- > cmds/qgroup.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/cmds/qgroup.c b/cmds/qgroup.c > index d9104d1a..265c4910 100644 > --- a/cmds/qgroup.c > +++ b/cmds/qgroup.c > @@ -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;
On Sun, Oct 08, 2023 at 09:17:17AM +0000, Sidong Yang wrote: > 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 <realwakka@gmail.com> Added to devel, thanks. I've also added the test case.
diff --git a/cmds/qgroup.c b/cmds/qgroup.c index d9104d1a..265c4910 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -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;
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 <realwakka@gmail.com> --- cmds/qgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+)