1 |
commit: 0467d4c73cc564101ceff32a3b74cc86ea36262c |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 19 11:48:20 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 19 11:48:20 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0467d4c7 |
7 |
|
8 |
libq/tree: Coverity 206569 String not terminated |
9 |
|
10 |
Help Coverity see the string is terminated, effectively turning a more |
11 |
expensive zalloc into malloc. |
12 |
|
13 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
14 |
|
15 |
libq/tree.c | 3 ++- |
16 |
1 file changed, 2 insertions(+), 1 deletion(-) |
17 |
|
18 |
diff --git a/libq/tree.c b/libq/tree.c |
19 |
index 1802d79..94f9665 100644 |
20 |
--- a/libq/tree.c |
21 |
+++ b/libq/tree.c |
22 |
@@ -793,10 +793,11 @@ tree_read_file_ebuild(tree_pkg_ctx *pkg_ctx) |
23 |
goto err; |
24 |
|
25 |
len = sizeof(*ret) + s.st_size + 1; |
26 |
- ret = xzalloc(len); |
27 |
+ ret = xmalloc(len); |
28 |
p = (char *)ret + sizeof(*ret); |
29 |
if ((off_t)fread(p, 1, s.st_size, f) != s.st_size) |
30 |
goto err; |
31 |
+ p[s.st_size] = '\0'; |
32 |
|
33 |
do { |
34 |
q = p; |