From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7B3C51382C5 for ; Mon, 25 May 2020 13:26:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 981DBE0831; Mon, 25 May 2020 13:26:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7A0AFE0831 for ; Mon, 25 May 2020 13:26:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B3FBA34EFE0 for ; Mon, 25 May 2020 13:26:05 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3DF35264 for ; Mon, 25 May 2020 13:26:03 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1590413115.93b42c880a13128663c6ddf2ee1a98b901ede6fa.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/tree.c X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 93b42c880a13128663c6ddf2ee1a98b901ede6fa X-VCS-Branch: master Date: Mon, 25 May 2020 13:26:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0162ddbc-8b8e-4a83-a19e-6f5b71e21937 X-Archives-Hash: 501b29d2917ce11882dd50c0019e126e commit: 93b42c880a13128663c6ddf2ee1a98b901ede6fa Author: Fabian Groffen gentoo org> AuthorDate: Mon May 25 13:25:15 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon May 25 13:25:15 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=93b42c88 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 gentoo.org> libq/tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libq/tree.c b/libq/tree.c index e4c4eb7..eb5f324 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 {