Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Wed, 27 Mar 2019 20:37:12
Message-Id: 1553718999.5afa37bd046ea35d9c68f43a1a28233bd0dbc7a7.grobian@gentoo
1 commit: 5afa37bd046ea35d9c68f43a1a28233bd0dbc7a7
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 27 20:36:39 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 27 20:36:39 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5afa37bd
7
8 qgrep: squash truncation warning on Solaris
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 qgrep.c | 8 ++++++--
13 1 file changed, 6 insertions(+), 2 deletions(-)
14
15 diff --git a/qgrep.c b/qgrep.c
16 index fdabf9c..a2b6a98 100644
17 --- a/qgrep.c
18 +++ b/qgrep.c
19 @@ -449,6 +449,7 @@ int qgrep_main(int argc, char **argv)
20 if ((p = strchr(ebuild, '\n')) != NULL)
21 *p = '\0';
22 if (show_name || (include_atoms != NULL)) {
23 + size_t l;
24 /* cut ".ebuild" */
25 if (p == NULL)
26 p = ebuild + strlen(ebuild);
27 @@ -460,8 +461,11 @@ int qgrep_main(int argc, char **argv)
28 /* find head of the ebuild basename */
29 if ((p = strchr(p, '/')) == NULL)
30 continue;
31 - /* find start of the pkg name */
32 - snprintf(name, sizeof(name), "%s/%s", ebuild, (p+1));
33 + /* find start of the pkg name, break up in two to
34 + * avoid warning about possible truncation (very
35 + * unlikely) */
36 + l = snprintf(name, sizeof(name), "%s", ebuild);
37 + snprintf(name + l, sizeof(name) - l, "%s", p);
38 /* restore the filepath */
39 *p = '/';
40 *(p + strlen(p)) = '.';