summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-07-07 18:34:12 +0000
committermillert <millert@openbsd.org>2015-07-07 18:34:12 +0000
commit30b613249c9f6651d318239d99e301bfd7399522 (patch)
treee228a45dce8e2da4b9f7ec29ac346b04038b1af3
parentAdd tests for incomming syslog messages over TCP. (diff)
downloadwireguard-openbsd-30b613249c9f6651d318239d99e301bfd7399522.tar.xz
wireguard-openbsd-30b613249c9f6651d318239d99e301bfd7399522.zip
Fix a regression caused by timespec changes when vi is run without
a file to edit. Based on a diff from Patrick Keshishian.
-rw-r--r--usr.bin/vi/common/exf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index 5a6436123fc..33aee068c9b 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exf.c,v 1.36 2015/04/24 21:48:31 brynet Exp $ */
+/* $OpenBSD: exf.c,v 1.37 2015/07/07 18:34:12 millert Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -185,7 +185,8 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
(void)snprintf(tname, sizeof(tname),
"%s/vi.XXXXXXXXXX", O_STR(sp, O_TMP_DIRECTORY));
fd = mkstemp(tname);
- if (fd == -1 || fchmod(fd, S_IRUSR | S_IWUSR) == -1) {
+ if (fd == -1 || fstat(fd, &sb) == -1 ||
+ fchmod(fd, S_IRUSR | S_IWUSR) == -1) {
msgq(sp, M_SYSERR,
"237|Unable to create temporary file");
if (fd != -1) {
@@ -210,8 +211,6 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
psize = 1024;
if (!LF_ISSET(FS_OPENERR))
F_SET(frp, FR_NEWFILE);
-
- (void)clock_gettime(CLOCK_REALTIME, &ep->mtim);
} else {
/*
* XXX
@@ -226,17 +225,18 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
psize = 1;
psize *= 1024;
- F_SET(ep, F_DEVSET);
- ep->mdev = sb.st_dev;
- ep->minode = sb.st_ino;
-
- ep->mtim = sb.st_mtim;
-
if (!S_ISREG(sb.st_mode))
msgq_str(sp, M_ERR, oname,
"238|Warning: %s is not a regular file");
}
+ /* Save device, inode and modification time. */
+ F_SET(ep, F_DEVSET);
+ ep->mdev = sb.st_dev;
+ ep->minode = sb.st_ino;
+
+ ep->mtim = sb.st_mtim;
+
/* Set up recovery. */
memset(&oinfo, 0, sizeof(RECNOINFO));
oinfo.bval = '\n'; /* Always set. */