summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Yanovich <jaredy@cvs.openbsd.org>2006-04-28 19:48:16 +0000
committerJared Yanovich <jaredy@cvs.openbsd.org>2006-04-28 19:48:16 +0000
commiteaa6d3992280a79f451b22c5b2cf5fc589421edb (patch)
tree23d26c1efa1ef4091310259ea93d7d4410766d02
parent06382ffde7d6cb8f7cc4524bf0444602312e9a82 (diff)
ensure NUL termination after read(); ok ray
-rw-r--r--usr.bin/vi/common/recover.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/vi/common/recover.c b/usr.bin/vi/common/recover.c
index 82375b21283..17897dd36e6 100644
--- a/usr.bin/vi/common/recover.c
+++ b/usr.bin/vi/common/recover.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: recover.c,v 1.9 2003/07/02 00:21:16 avsm Exp $ */
+/* $OpenBSD: recover.c,v 1.10 2006/04/28 19:48:15 jaredy Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -815,6 +815,7 @@ rcv_gets(buf, len, fd)
if ((nr = read(fd, buf, len - 1)) == -1)
return (NULL);
+ buf[nr] = '\0';
if ((p = strchr(buf, '\n')) == NULL)
return (NULL);
(void)lseek(fd, (off_t)((p - buf) + 1), SEEK_SET);