summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2018-09-12 22:10:35 +0000
committerchristos <christos@NetBSD.org>2018-09-12 22:10:35 +0000
commite7eb7a854b15c8fc02489678ef583bbd295a0076 (patch)
tree0e7d8e1fcf3e6867070a4644fa9450bc45a5d6a3 /lib/libedit
parent96be7f5ccc2b0adddcf58a84b18b2357b24d6b52 (diff)
PR/53597: Yasuhiro Horimoto: Avoid segmentation fault in bad history file.
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/history.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libedit/history.c b/lib/libedit/history.c
index 86a40e42b5f..331a0af5d43 100644
--- a/lib/libedit/history.c
+++ b/lib/libedit/history.c
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.59 2017/12/23 18:25:03 uwe Exp $ */
+/* $NetBSD: history.c,v 1.60 2018/09/12 22:10:35 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.59 2017/12/23 18:25:03 uwe Exp $");
+__RCSID("$NetBSD: history.c,v 1.60 2018/09/12 22:10:35 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -775,6 +775,7 @@ history_load(TYPE(History) *h, const char *fname)
char *ptr;
int i = -1;
TYPE(HistEvent) ev;
+ Char *decode_result;
#ifndef NARROWCHAR
static ct_buffer_t conv;
#endif
@@ -807,6 +808,9 @@ history_load(TYPE(History) *h, const char *fname)
ptr = nptr;
}
(void) strunvis(ptr, line);
+ decode_result = ct_decode_string(ptr, &conv);
+ if (decode_result == NULL)
+ continue;
if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) {
i = -1;
goto oomem;