Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit PR/53597: Yasuhiro Horimoto: Avoid segmentation ...



details:   https://anonhg.NetBSD.org/src/rev/6c50cb4a0690
branches:  trunk
changeset: 433401:6c50cb4a0690
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Sep 12 22:10:35 2018 +0000

description:
PR/53597: Yasuhiro Horimoto: Avoid segmentation fault in bad history file.

diffstat:

 lib/libedit/history.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 66900dfa06f4 -r 6c50cb4a0690 lib/libedit/history.c
--- a/lib/libedit/history.c     Wed Sep 12 22:10:07 2018 +0000
+++ b/lib/libedit/history.c     Wed Sep 12 22:10:35 2018 +0000
@@ -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 @@
        char *ptr;
        int i = -1;
        TYPE(HistEvent) ev;
+       Char *decode_result;
 #ifndef NARROWCHAR
        static ct_buffer_t conv;
 #endif
@@ -807,6 +808,9 @@
                        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;



Home | Main Index | Thread Index | Old Index