Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit make sure we have space for NUL and NUL terminat...
details: https://anonhg.NetBSD.org/src/rev/74af0f4fb024
branches: trunk
changeset: 341119:74af0f4fb024
user: christos <christos%NetBSD.org@localhost>
date: Mon Oct 19 00:36:27 2015 +0000
description:
make sure we have space for NUL and NUL terminate buffer array (Jilles Tjoelker)
diffstat:
lib/libedit/vi.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (34 lines):
diff -r 705d41f1ddc0 -r 74af0f4fb024 lib/libedit/vi.c
--- a/lib/libedit/vi.c Mon Oct 19 00:29:57 2015 +0000
+++ b/lib/libedit/vi.c Mon Oct 19 00:36:27 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.45 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: vi.c,v 1.46 2015/10/19 00:36:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vi.c,v 1.45 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.46 2015/10/19 00:36:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1038,12 +1038,13 @@
while (waitpid(pid, &status, 0) != pid)
continue;
lseek(fd, (off_t)0, SEEK_SET);
- st = read(fd, cp, TMP_BUFSIZ);
+ st = read(fd, cp, TMP_BUFSIZ - 1);
if (st > 0) {
+ cp[st] = '\0';
len = (size_t)(el->el_line.lastchar -
el->el_line.buffer);
len = ct_mbstowcs(el->el_line.buffer, cp, len);
- if (len > 0 && el->el_line.buffer[len -1] == '\n')
+ if (len > 0 && el->el_line.buffer[len - 1] == '\n')
--len;
}
else
Home |
Main Index |
Thread Index |
Old Index