summaryrefslogtreecommitdiffstats
path: root/cmd-save-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-26 21:13:06 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-26 21:13:06 +0000
commit539c73bdb1865ad57600e3759f2475adef79ab41 (patch)
treef141635c305086a3ba63333691202b9e3978c201 /cmd-save-buffer.c
parent6dc6333323cce1ccc9aaec7ef9e7e200919204e1 (diff)
Reset the umask right after fopen to avoid leaving it changed on error, noticed
by deraadt@.
Diffstat (limited to 'cmd-save-buffer.c')
-rw-r--r--cmd-save-buffer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c
index 5a779dc1..33859fd6 100644
--- a/cmd-save-buffer.c
+++ b/cmd-save-buffer.c
@@ -70,6 +70,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
f = fopen(data->arg, "ab");
else
f = fopen(data->arg, "wb");
+ umask(mask);
if (f == NULL) {
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
return (-1);
@@ -82,7 +83,6 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
fclose(f);
- umask(mask);
return (0);
}