aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-07-07 11:38:59 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-07-07 11:38:59 +0200
commitafa4021ded6e58da4ee4d01dbf4e503d3711d002 (patch)
treec03968f312314731217d98de239cfeaff7dd7fb7
parentc425082394c2ddbb3c450f0b2843e5c77be4c7e9 (diff)
downloadlibssh-afa4021ded6e58da4ee4d01dbf4e503d3711d002.tar.gz
libssh-afa4021ded6e58da4ee4d01dbf4e503d3711d002.tar.xz
libssh-afa4021ded6e58da4ee4d01dbf4e503d3711d002.zip
tests: Add umask() around mkstemp()
CID 1391450 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_knownhosts_parsing.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/unittests/torture_knownhosts_parsing.c b/tests/unittests/torture_knownhosts_parsing.c
index 25d416b7..099a4594 100644
--- a/tests/unittests/torture_knownhosts_parsing.c
+++ b/tests/unittests/torture_knownhosts_parsing.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include <sys/stat.h>
+
#define LIBSSH_STATIC
#include <libssh/priv.h>
#include "torture.h"
@@ -20,13 +22,16 @@ static int setup_knownhosts_file(void **state)
char *tmp_file = NULL;
size_t nwritten;
FILE *fp = NULL;
+ mode_t mask;
int fd;
tmp_file = strdup(TMP_FILE_NAME);
assert_non_null(tmp_file);
*state = tmp_file;
+ mask = umask(S_IRWXO | S_IRWXG);
fd = mkstemp(tmp_file);
+ umask(mask);
assert_return_code(fd, errno);
fp = fdopen(fd, "w");