diff options
author | Fabian Groffen <grobian@gentoo.org> | 2020-05-25 15:25:15 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2020-05-25 15:25:15 +0200 |
commit | 93b42c880a13128663c6ddf2ee1a98b901ede6fa (patch) | |
tree | 0d61ba079c9f953198873db9796d63be506f2fed | |
parent | tests/valgrind-wrapper: use --track-origins for easier debugging (diff) | |
download | portage-utils-93b42c880a13128663c6ddf2ee1a98b901ede6fa.tar.gz portage-utils-93b42c880a13128663c6ddf2ee1a98b901ede6fa.tar.bz2 portage-utils-93b42c880a13128663c6ddf2ee1a98b901ede6fa.zip |
libq/tree: avoid invalid read in tree_foreach_packages
eat_file doesn't return how much data was written, only produced buffer
size, so need to calculate length there
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r-- | libq/tree.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libq/tree.c b/libq/tree.c index e4c4eb73..eb5f3242 100644 --- a/libq/tree.c +++ b/libq/tree.c @@ -1277,11 +1277,11 @@ tree_close_pkg(tree_pkg_ctx *pkg_ctx) static int tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb callback, void *priv) { - char *p = ctx->pkgs; + char *p; char *q; char *c; char pkgname[_Q_PATH_MAX]; - size_t len = ctx->pkgslen; + size_t len; int ret = 0; depend_atom *query = ctx->query_atom; @@ -1307,6 +1307,9 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb callback, void *priv) close(fd); } + p = ctx->pkgs; + len = strlen(ctx->pkgs); /* sucks, need eat_file change */ + memset(&meta, 0, sizeof(meta)); do { |