Module Name: src
Committed By: christos
Date: Mon Jul 18 16:58:04 UTC 2016
Modified Files:
src/external/bsd/mdocml/dist: tag.c
Log Message:
CID 1349652: Set umask before mkstemp
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/mdocml/dist/tag.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/mdocml/dist/tag.c
diff -u src/external/bsd/mdocml/dist/tag.c:1.1.1.1 src/external/bsd/mdocml/dist/tag.c:1.2
--- src/external/bsd/mdocml/dist/tag.c:1.1.1.1 Fri Jul 15 10:25:56 2016
+++ src/external/bsd/mdocml/dist/tag.c Mon Jul 18 12:58:04 2016
@@ -52,6 +52,7 @@ tag_init(void)
{
struct sigaction sa;
int ofd;
+ mode_t omask;
ofd = -1;
tag_files.tfd = -1;
@@ -86,10 +87,12 @@ tag_init(void)
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 @@ tag_init(void)
mandoc_ohash_init(&tag_data, 4, offsetof(struct tag_entry, s));
return &tag_files;
-
+fail1:
+ (void)umask(omask);
fail:
tag_unlink();
if (ofd != -1)