commit:     d314b816ef29bf1948cd9f747a22c2565e88bf76
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 17:03:56 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 17:03:56 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d314b816

libq/tree: fix Coverity uninitialised memory use CID 248874

tree_read_file_pms was using buf, which was never initialised after
some changes from the past

remove entire buf, and use the paths from pkg and cat ctxs in the
printfs directly

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

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

diff --git a/libq/tree.c b/libq/tree.c
index 1e0e623..d71ee74 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -676,7 +676,6 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
        FILE *f;
        tree_pkg_meta *ret = NULL;
        size_t len;
-       char buf[_Q_PATH_MAX];
 
        if ((f = fdopen(pkg_ctx->fd, "r")) == NULL)
                goto err;
@@ -695,7 +694,8 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
        ret->Q_DEPEND = ptr;
 #define next_line(curr, next) \
        if ((ptr = strchr(ret->Q_##curr, '\n')) == NULL) { \
-               warn("Invalid cache file for '%s'", buf); \
+               warn("Invalid cache file for '%s/%s'", \
+                        pkg_ctx->cat_ctx->name, pkg_ctx->name); \
                goto err; \
        } \
        ret->Q_##next = ptr+1; \
@@ -718,8 +718,8 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
 #undef next_line
        ptr = strchr(ptr+1, '\n');
        if (ptr == NULL) {
-               warn("Invalid cache file for '%s' - could not find end of cache 
data",
-                               buf);
+               warn("Invalid cache file for '%s/%s' - could not find end of 
cache data",
+                        pkg_ctx->cat_ctx->name, pkg_ctx->name);
                goto err;
        }
        *ptr = '\0';

Reply via email to