summaryrefslogtreecommitdiffstats
path: root/discover/paths.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-11-12 10:04:23 +1100
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-12-18 11:15:58 +1100
commit2c6137dffb1518f5102170cf0eda26c83a31bc63 (patch)
treebd31842412fe6a4b2e4d87eb766470e43be3ba1e /discover/paths.c
parent999fd1a2053421b55cdd876049c40beb2921807f (diff)
downloadtalos-petitboot-2c6137dffb1518f5102170cf0eda26c83a31bc63.tar.gz
talos-petitboot-2c6137dffb1518f5102170cf0eda26c83a31bc63.zip
discover: Set umask before mkstemp()
Fixes Coverity defect #30479 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover/paths.c')
-rw-r--r--discover/paths.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/discover/paths.c b/discover/paths.c
index c25671b..1269dde 100644
--- a/discover/paths.c
+++ b/discover/paths.c
@@ -6,6 +6,8 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <talloc/talloc.h>
#include <system/system.h>
@@ -49,9 +51,12 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b)
static char *local_name(void *ctx)
{
char *ret, tmp[] = "/tmp/pb-XXXXXX";
+ mode_t oldmask;
int fd;
+ oldmask = umask(0644);
fd = mkstemp(tmp);
+ umask(oldmask);
if (fd < 0)
return NULL;
OpenPOWER on IntegriCloud