diff options
author | 2009-10-26 21:13:06 +0000 | |
---|---|---|
committer | 2009-10-26 21:13:06 +0000 | |
commit | 6653eead5a4c2149d31d8abc2a9b975cd7973c38 (patch) | |
tree | 95a64286544740ae751ec4e97d6498fa81e01654 /usr.bin/tmux/cmd-save-buffer.c | |
parent | Use strlcpy instead of strncpy, pointed out by deraadt. (diff) | |
download | wireguard-openbsd-6653eead5a4c2149d31d8abc2a9b975cd7973c38.tar.xz wireguard-openbsd-6653eead5a4c2149d31d8abc2a9b975cd7973c38.zip |
Reset the umask right after fopen to avoid leaving it changed on error, noticed
by deraadt@.
Diffstat (limited to 'usr.bin/tmux/cmd-save-buffer.c')
-rw-r--r-- | usr.bin/tmux/cmd-save-buffer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c index a9462e72990..ef71693ac33 100644 --- a/usr.bin/tmux/cmd-save-buffer.c +++ b/usr.bin/tmux/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-save-buffer.c,v 1.4 2009/09/07 18:50:45 nicm Exp $ */ +/* $OpenBSD: cmd-save-buffer.c,v 1.5 2009/10/26 21:13:06 nicm 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); } |