Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/48876: Dmitriy Grigoryev: Core dump in readli...



details:   https://anonhg.NetBSD.org/src/rev/8bb36f9f32be
branches:  trunk
changeset: 329725:8bb36f9f32be
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jun 05 22:07:42 2014 +0000

description:
PR/48876: Dmitriy Grigoryev: Core dump in readline lib on attempted expansion
Make sure we have 2 matches before calling strcmp().

diffstat:

 lib/libedit/filecomplete.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 0b7ebb66eeca -r 8bb36f9f32be lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Thu Jun 05 22:00:22 2014 +0000
+++ b/lib/libedit/filecomplete.c        Thu Jun 05 22:07:42 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.31 2011/09/16 16:13:16 plunky Exp $ */
+/*     $NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 christos Exp $       */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.31 2011/09/16 16:13:16 plunky Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -490,7 +490,8 @@
                if (what_to_do == '?')
                        goto display_matches;
 
-               if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
+               if (matches[2] == NULL &&
+                   (matches[1] == NULL || strcmp(matches[0], matches[1]) == 0)) {
                        /*
                         * We found exact match. Add a space after
                         * it, unless we do filename completion and the



Home | Main Index | Thread Index | Old Index