mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[mkstemp] set umask
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <uwac/config.h>
|
||||
|
||||
@@ -178,6 +179,14 @@ int uwac_os_epoll_create_cloexec(void)
|
||||
return set_cloexec_or_close(fd);
|
||||
}
|
||||
|
||||
static int secure_mkstemp(char* tmpname)
|
||||
{
|
||||
const mode_t mask = umask(S_IRWXU);
|
||||
int fd = mkstemp(tmpname);
|
||||
(void)umask(mask);
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int create_tmpfile_cloexec(char* tmpname)
|
||||
{
|
||||
int fd = 0;
|
||||
@@ -190,7 +199,7 @@ static int create_tmpfile_cloexec(char* tmpname)
|
||||
unlink(tmpname);
|
||||
|
||||
#else
|
||||
fd = mkstemp(tmpname);
|
||||
fd = secure_mkstemp(tmpname);
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user