]> granicus.if.org Git - p11-kit/commitdiff
trust: Set umask before calling mkstemp
authorDaiki Ueno <dueno@redhat.com>
Tue, 16 Oct 2018 16:20:12 +0000 (18:20 +0200)
committerDaiki Ueno <ueno@gnu.org>
Wed, 17 Oct 2018 08:13:32 +0000 (10:13 +0200)
trust/save.c

index 8184e13a7125af246059029755c5cc418ef99571..bb773486470aa35f860473d0543895a944965110 100644 (file)
@@ -95,6 +95,7 @@ p11_save_open_file (const char *path,
 {
        p11_save_file *file;
        char *temp;
+       mode_t mode;
        int fd;
 
        return_val_if_fail (path != NULL, NULL);
@@ -105,7 +106,9 @@ p11_save_open_file (const char *path,
        if (asprintf (&temp, "%s%s.XXXXXX", path, extension) < 0)
                return_val_if_reached (NULL);
 
+       mode = umask (0077);
        fd = mkstemp (temp);
+       umask (mode);
        if (fd < 0) {
                p11_message_err (errno, "couldn't create file: %s%s", path, extension);
                free (temp);