commit:     06458fcdfeb3d0b267b18dba043028d6accf3b0d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 11:42:05 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 11:42:05 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=06458fcd

qcheck: address Coverity 206997 Insecure temporary file

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

 qcheck.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qcheck.c b/qcheck.c
index 1d8521a..72a68a9 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -105,7 +105,12 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        /* Open contents_update, if needed */
        if (state->qc_update) {
                char tempfile[] = "qcheck-tmp-XXXXXX";
-               int fd = mkstemp(tempfile);
+               mode_t mask;
+               int fd;
+
+               mask = umask(0077);
+               fd = mkstemp(tempfile);
+               umask(mask);
                if (fd == -1 || (fp_contents_update = fdopen(fd, "w+")) == 
NULL) {
                        if (fd >= 0)
                                close(fd);

Reply via email to