[PATCH 10/11] discover: Set umask before mkstemp()

Samuel Mendoza-Jonas sam.mj at au1.ibm.com
Thu Nov 12 15:34:40 AEDT 2015


Fixes Coverity defect #30479

Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
---
 discover/paths.c | 5 +++++
 1 file changed, 5 insertions(+)

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;
-- 
2.6.2



More information about the Petitboot mailing list