From: Steinar H. Gunderson Date: Fri, 19 Apr 2013 17:23:24 +0000 (+0200) Subject: Set umask security before calling mkstemp(). X-Git-Tag: 1.0.0~70 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=b8352f46d7d45631d38fc120ccda09268818a686;ds=sidebyside Set umask security before calling mkstemp(). Found by Coverity Scan. --- diff --git a/util.cpp b/util.cpp index b8862ed..45bf5b5 100644 --- a/util.cpp +++ b/util.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "log.h" #include "util.h" @@ -12,7 +14,9 @@ using namespace std; int make_tempfile(const std::string &contents) { char filename[] = "/tmp/cubemap.XXXXXX"; + mode_t old_umask = umask(0600); int fd = mkstemp(filename); + umask(old_umask); if (fd == -1) { log_perror("mkstemp"); return -1;