]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
CID 1358898: Set umask if we're running under coverity
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 26 May 2017 14:00:06 +0000 (10:00 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 26 May 2017 19:04:19 +0000 (15:04 -0400)
src/main/tls/validate.c

index 07d287ba8106ffe635fbd9ead3f3b69eeec57ccb..122354148033a732cf5e2d88e05a28f5dc1d638e 100644 (file)
@@ -257,6 +257,16 @@ int tls_validate_cert_cb(int ok, X509_STORE_CTX *x509_ctx)
 
                snprintf(filename, sizeof(filename), "%s/%s.client.XXXXXXXX",
                         conf->verify_tmp_dir, main_config.name);
+
+#ifdef __COVERITY__
+               /*
+                *      POSIX-2008 requires that mkstemp creates the file
+                *      with 0600 permissions.  So setting umask is pointless
+                *      and although it won't cause crashes, will cause
+                *      race conditions in threaded environments.
+                */
+               umask(0600);
+#endif
                fd = mkstemp(filename);
                if (fd < 0) {
                        RDEBUG("Failed creating file in %s: %s",