summaryrefslogtreecommitdiff
path: root/lib/libedit/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit/hist.c')
-rw-r--r--lib/libedit/hist.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libedit/hist.c b/lib/libedit/hist.c
index 394df63e9d3..b9a6e20c677 100644
--- a/lib/libedit/hist.c
+++ b/lib/libedit/hist.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -35,7 +37,11 @@
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
@@ -100,7 +106,8 @@ hist_get(el)
int h;
if (el->el_history.eventno == 0) { /* if really the current line */
- (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ);
+ (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ - 1);
+ el->el_line.buffer[EL_BUFSIZ - 1] = '\0';
el->el_line.lastchar = el->el_line.buffer +
(el->el_history.last - el->el_history.buf);
@@ -128,7 +135,8 @@ hist_get(el)
return CC_ERROR;
}
- (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ);
+ (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ - 1);
+ el->el_line.buffer[EL_BUFSIZ - 1] = '\0';
el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer);
if (el->el_line.lastchar > el->el_line.buffer) {