Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Thu, 29 Apr 2021 13:24:33
Message-Id: 1619702607.09b817763d3b03d9ccee92ddd4fa13edb82d53a9.grobian@gentoo
1 commit: 09b817763d3b03d9ccee92ddd4fa13edb82d53a9
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 29 13:23:27 2021 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 29 13:23:27 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=09b81776
7
8 tree: avoid crash in tree_foreach_packages when category doesn't exist
9
10 This can be observed when reading a Packages file that refers to binpkgs
11 that do not exist.
12
13 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
14
15 libq/tree.c | 10 ++++++++++
16 1 file changed, 10 insertions(+)
17
18 diff --git a/libq/tree.c b/libq/tree.c
19 index a947735..04bf468 100644
20 --- a/libq/tree.c
21 +++ b/libq/tree.c
22 @@ -1375,6 +1375,16 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb callback, void *priv)
23 tree_close_cat(cat);
24 }
25 pkg.cat_ctx = cat = tree_open_cat(ctx, atom->CATEGORY);
26 + if (cat == NULL) {
27 + /* probably dir doesn't exist or something, skip
28 + * this one */
29 + memset(&meta, 0, sizeof(meta));
30 + if (len > 0) { /* hop over \n */
31 + p++;
32 + len--;
33 + }
34 + continue;
35 + }
36 cat->pkg_ctxs = (tree_pkg_ctx **)atom; /* for name */
37 }
38 pkgnamelen = snprintf(pkgname, sizeof(pkgname),