commit:     89840fe93db36a37261f2427cd4e44273a783d6d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 31 13:07:01 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Dec 31 13:07:01 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=89840fe9

libq/tree: make sure binpkg_isgpkg is set correctly

- do proper maths to calculate "the end of the string" to compare the
  suffix
- propagate binpkg_isgpkg for tree_match_atom

Bug: https://bugs.gentoo.org/968185
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/tree.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index 139e0a0..e1978c7 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1700,20 +1700,20 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
                                if (meta.Q_PATH != NULL) {
                                        size_t plen = strlen(meta.Q_PATH);
                                        if (plen > sizeof(".tbz2") - 1 &&
-                                               memcmp(meta.Q_PATH + plen - 
sizeof(".tbz2") - 1,
+                                               memcmp(meta.Q_PATH + plen - 
(sizeof(".tbz2") - 1),
                                                           ".tbz2", 
sizeof(".tbz2") - 1) == 0)
                                        {
                                                pkgnamelen = snprintf(pkgname, 
sizeof(pkgname),
                                                                                
          "%s.tbz2", atom->PF);
                                                pkgname[pkgnamelen - 
(sizeof(".tbz2") - 1)] = '\0';
-                                       }
-                                       if (plen > sizeof(".gpkg.tar") - 1 &&
-                                               memcmp(meta.Q_PATH + plen - 
sizeof(".gpkg.tar") - 1,
+                                       } else if (plen > sizeof(".gpkg.tar") - 
1 &&
+                                               memcmp(meta.Q_PATH + plen - 
(sizeof(".gpkg.tar") - 1),
                                                           ".gpkg.tar", 
sizeof(".gpkg.tar") - 1) == 0)
                                        {
                                                pkgnamelen = snprintf(pkgname, 
sizeof(pkgname),
                                                                                
          "%s.gpkg.tar", atom->PF);
                                                pkgname[pkgnamelen - 
(sizeof(".gpkg.tar") - 1)] = '\0';
+                                               pkg.binpkg_isgpkg = 1;
                                        }
                                }
                                if (pkgnamelen == 0) {
@@ -2238,8 +2238,8 @@ tree_match_atom_cache_populate_cb(tree_pkg_ctx *ctx, void 
*priv)
                         * xpak archive, so can just take it over */
                        pkg->meta = meta;
                        ctx->meta = NULL;  /* avoid double free */
-                       pkg->binpkg_isgpkg = ctx->binpkg_isgpkg;
                }
+               pkg->binpkg_isgpkg = ctx->binpkg_isgpkg;
        } else {
                pkg->meta = NULL;
        }

Reply via email to