summaryrefslogtreecommitdiffstats
path: root/cmd-save-buffer.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-28 23:08:52 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-28 23:08:52 +0000
commitce743b205884853526709aff2b784ea67dd80daa (patch)
tree4e8f9f607930190dda353feda3de3bd3912873f5 /cmd-save-buffer.c
parent88bb9381b267f6411af6438a11209ed53110e4a4 (diff)
Sync OpenBSD patchset 464:
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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c
index ca11bae4..cd269d15 100644
--- a/cmd-save-buffer.c
+++ b/cmd-save-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-save-buffer.c,v 1.8 2009-09-07 23:48:54 tcunha Exp $ */
+/* $Id: cmd-save-buffer.c,v 1.9 2009-10-28 23:08:52 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -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);
}