From: djm Date: Mon, 26 Jan 2015 13:36:53 +0000 (+0000) Subject: properly restore umask X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=05698091f75ed0f1759dcafbb3647c1d5e3769c1;p=openbsd properly restore umask --- diff --git a/usr.bin/ssh/hostfile.c b/usr.bin/ssh/hostfile.c index 89a50ada852..ee327fabddd 100644 --- a/usr.bin/ssh/hostfile.c +++ b/usr.bin/ssh/hostfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.c,v 1.62 2015/01/26 03:04:45 djm Exp $ */ +/* $OpenBSD: hostfile.c,v 1.63 2015/01/26 13:36:53 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -548,6 +548,8 @@ hostfile_replace_entries(const char *filename, const char *host, mode_t omask; size_t i; + omask = umask(077); + memset(&ctx, 0, sizeof(ctx)); ctx.host = host; ctx.quiet = quiet; @@ -565,7 +567,6 @@ hostfile_replace_entries(const char *filename, const char *host, goto fail; } - omask = umask(077); if ((fd = mkstemp(temp)) == -1) { oerrno = errno; error("%s: mkstemp: %s", __func__, strerror(oerrno)); @@ -633,6 +634,7 @@ hostfile_replace_entries(const char *filename, const char *host, if (ctx.out != NULL) fclose(ctx.out); free(ctx.skip_keys); + umask(omask); if (r == SSH_ERR_SYSTEM_ERROR) errno = oerrno; return r;