]> git.sesse.net Git - cubemap/commitdiff
Set umask security before calling mkstemp().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Apr 2013 17:23:24 +0000 (19:23 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Apr 2013 17:23:24 +0000 (19:23 +0200)
Found by Coverity Scan.

util.cpp

index b8862ed48c79719b632dd1575a6cd1cc6e057b39..45bf5b52453309b1ff178d63ed1d64603e76b9de 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -3,6 +3,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "log.h"
 #include "util.h"
 
 #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";
 int make_tempfile(const std::string &contents)
 {
        char filename[] = "/tmp/cubemap.XXXXXX";
+       mode_t old_umask = umask(0600);
        int fd = mkstemp(filename);
        int fd = mkstemp(filename);
+       umask(old_umask);
        if (fd == -1) {
                log_perror("mkstemp");
                return -1;
        if (fd == -1) {
                log_perror("mkstemp");
                return -1;