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: Sun, 19 Jan 2020 12:37:21
Message-Id: 1579434125.06458fcdfeb3d0b267b18dba043028d6accf3b0d.grobian@gentoo
1 commit: 06458fcdfeb3d0b267b18dba043028d6accf3b0d
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 19 11:42:05 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 19 11:42:05 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=06458fcd
7
8 qcheck: address Coverity 206997 Insecure temporary file
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 qcheck.c | 7 ++++++-
13 1 file changed, 6 insertions(+), 1 deletion(-)
14
15 diff --git a/qcheck.c b/qcheck.c
16 index 1d8521a..72a68a9 100644
17 --- a/qcheck.c
18 +++ b/qcheck.c
19 @@ -105,7 +105,12 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
20 /* Open contents_update, if needed */
21 if (state->qc_update) {
22 char tempfile[] = "qcheck-tmp-XXXXXX";
23 - int fd = mkstemp(tempfile);
24 + mode_t mask;
25 + int fd;
26 +
27 + mask = umask(0077);
28 + fd = mkstemp(tempfile);
29 + umask(mask);
30 if (fd == -1 || (fp_contents_update = fdopen(fd, "w+")) == NULL) {
31 if (fd >= 0)
32 close(fd);