commit:     30107261579a462740c37af9d42f3cf6d0863cea
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 26 17:00:04 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 26 17:00:04 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=30107261

libq/tree: fix off-by-one in tree_foreach_pkg_gtree, CID 557240

Make sure we always have enough memory to write the trailing \0.

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

 libq/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libq/tree.c b/libq/tree.c
index 7e2833f3..4844e088 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -324,7 +324,7 @@ static int tree_foreach_pkg_gtree
 
       /* ok, we're in business */
       len = archive_entry_size(entry);
-      if (len > rlen)
+      if (len + 1 > rlen)
       {
         rlen = len + 1;
         rbuf = xrealloc(rbuf, rlen);

Reply via email to