commit: c4e0ef9df105c2a1459d283cd3d977fcd31d363d
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:14:07 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:14:07 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c4e0ef9d
libq/tree: fix Coverity 206551 String not null terminated
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libq/tree.c b/libq/tree.c
index 2efdb7c..9645237 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -618,10 +618,11 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
goto err;
len = sizeof(*ret) + s.st_size + 1;
- ret = xzalloc(len);
+ ret = xmalloc(len);
ptr = (char*)ret + sizeof(*ret);
if ((off_t)fread(ptr, 1, s.st_size, f) != s.st_size)
goto err;
+ ptr[s.st_size] = '\0';
ret->Q_DEPEND = ptr;
#define next_line(curr, next) \