Prevent nvi from looping infinitely when it can't create a temporary file

because of a weird umask for example.
Make it exit instead.
This differs from the OpenBSD behaviour and is believed to be more correct.

Reported by Thomas Klausner in private e-mail, followed by a small discussion in
tech-userlevel a while ago.
This commit is contained in:
aymeric 2001-08-17 21:33:46 +00:00
parent e5769f5f01
commit ca334636ac
1 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exf.c,v 1.3 2001/03/31 11:37:45 aymeric Exp $ */
/* $NetBSD: exf.c,v 1.4 2001/08/17 21:33:46 aymeric Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -184,6 +184,11 @@ file_init(sp, frp, rcv_name, flags)
*/
oname = frp->name;
if (LF_ISSET(FS_OPENERR) || oname == NULL || !exists) {
/*
* Don't try to create a temporary support file twice.
*/
if (frp->tname != NULL)
goto err;
if (opts_empty(sp, O_DIRECTORY, 0))
goto err;
(void)snprintf(tname, sizeof(tname),
@ -266,7 +271,7 @@ file_init(sp, frp, rcv_name, flags)
* be read. This isn't useful for single files from a command
* line, but it's quite useful for "vi *.c", since you can skip
* past files that you can't read.
*/
*/
open_err = 1;
goto oerr;
}