From afa4021ded6e58da4ee4d01dbf4e503d3711d002 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 7 Jul 2018 11:38:59 +0200 Subject: [PATCH] tests: Add umask() around mkstemp() CID 1391450 Signed-off-by: Andreas Schneider --- tests/unittests/torture_knownhosts_parsing.c | 5 +++++ 1 file changed, 5 insertions(+) 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 + #define LIBSSH_STATIC #include #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");