Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/mdocml/dist CID 1349652: Set umask before mkstemp



details:   https://anonhg.NetBSD.org/src/rev/bcbca2eb147c
branches:  trunk
changeset: 346536:bcbca2eb147c
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jul 18 16:58:04 2016 +0000

description:
CID 1349652: Set umask before mkstemp

diffstat:

 external/bsd/mdocml/dist/tag.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r c59ff47ea13b -r bcbca2eb147c external/bsd/mdocml/dist/tag.c
--- a/external/bsd/mdocml/dist/tag.c    Mon Jul 18 16:56:04 2016 +0000
+++ b/external/bsd/mdocml/dist/tag.c    Mon Jul 18 16:58:04 2016 +0000
@@ -52,6 +52,7 @@
 {
        struct sigaction         sa;
        int                      ofd;
+       mode_t                   omask;
 
        ofd = -1;
        tag_files.tfd = -1;
@@ -86,10 +87,12 @@
            sizeof(tag_files.ofn));
        (void)strlcpy(tag_files.tfn, "/tmp/man.XXXXXXXXXX",
            sizeof(tag_files.tfn));
+       omask = umask(077);
        if ((ofd = mkstemp(tag_files.ofn)) == -1)
-               goto fail;
+               goto fail1;
        if ((tag_files.tfd = mkstemp(tag_files.tfn)) == -1)
-               goto fail;
+               goto fail1;
+       (void)umask(omask);
        if (dup2(ofd, STDOUT_FILENO) == -1)
                goto fail;
        close(ofd);
@@ -101,7 +104,8 @@
 
        mandoc_ohash_init(&tag_data, 4, offsetof(struct tag_entry, s));
        return &tag_files;
-
+fail1:
+       (void)umask(omask);
 fail:
        tag_unlink();
        if (ofd != -1)



Home | Main Index | Thread Index | Old Index