]> git.ozlabs.org Git - petitboot/commitdiff
discover: Set umask before mkstemp()
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Wed, 11 Nov 2015 23:04:23 +0000 (10:04 +1100)
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Fri, 18 Dec 2015 00:15:58 +0000 (11:15 +1100)
Fixes Coverity defect #30479

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover/paths.c

index c25671b17a6a22404600da2a64cc9febca93f84f..1269dded35b73960c6b3d51c00efcd1b6e6aaafa 100644 (file)
@@ -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;