NetBSD Problem Report #44186

From www@NetBSD.org  Thu Dec  2 22:46:08 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 0808363BA9C
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  2 Dec 2010 22:46:08 +0000 (UTC)
Message-Id: <20101202224607.AB61C63B95F@www.NetBSD.org>
Date: Thu,  2 Dec 2010 22:46:07 +0000 (UTC)
From: ac3.87.z@gmail.com
Reply-To: ac3.87.z@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Problem with rl_display_match_list in libedit
X-Send-Pr-Version: www-1.0

>Number:         44186
>Category:       lib
>Synopsis:       Problem with rl_display_match_list in libedit
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 02 22:50:00 +0000 2010
>Closed-Date:    Mon Dec 06 02:26:01 +0000 2010
>Last-Modified:  Mon Dec 06 02:26:01 +0000 2010
>Originator:     Sergio Acereda
>Release:        -current
>Organization:
>Environment:
NetBSD new-host-4 5.99.40 NetBSD 5.99.40 (DM) #0: Sun Nov 21 21:37:10 CET 2010  root@.:/usr/obj/sys/arch/amd64/compile/DM amd64

>Description:
This problem may be related to PR 44183.

rl_display_match_list prints (null) entries



>How-To-Repeat:
Apply the following patch and compile lib/libedit with MKDEBUGLIB=yes, and then try to run 'test.c' with no arguments and with one argument only.

In the first case, the program prints (null) entry. 
In the second case, the assertion will fail.

test.c:
#include <readline/readline.h>

int main(int argc, char ** argv) {
  rl_initialize();  
  rl_display_match_list(argv, argc, 30);
  return 0;
}


Index: lib/libedit/filecomplete.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/filecomplete.c,v
retrieving revision 1.22
diff -u -r1.22 filecomplete.c
--- lib/libedit/filecomplete.c	2 Dec 2010 04:42:46 -0000	1.22
+++ lib/libedit/filecomplete.c	2 Dec 2010 22:43:11 -0000
@@ -33,10 +33,10 @@
 #if !defined(lint) && !defined(SCCSID)
 __RCSID("$NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $");
 #endif /* not lint && not SCCSID */
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
+#include <assert.h>
 #include <dirent.h>
 #include <string.h>
 #include <pwd.h>
@@ -332,7 +332,7 @@
 {
 	const char *s1 = ((const char * const *)i1)[0];
 	const char *s2 = ((const char * const *)i2)[0];
-
+	assert(s1 && s2);
 	return strcasecmp(s1, s2);
 }







>Fix:
The patch suggested in PR 44183 works as expected

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 03 Dec 2010 08:02:11 +0000
State-Changed-Why:
Do you have revision 1.22 of filecomplete.c?


From: Sergio Acereda <ac3.87.z@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org,
 netbsd-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 dholland@NetBSD.org
Subject: Re: lib/44186 (Problem with rl_display_match_list in libedit)
Date: Sat, 4 Dec 2010 08:34:10 +0100

 Yes, that test.c crashes with the revision 1.22 of filecomplete.c

 On 3 Dec, 2010, at 09:02 , dholland@NetBSD.org wrote:

 > Synopsis: Problem with rl_display_match_list in libedit
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Fri, 03 Dec 2010 08:02:11 +0000
 > State-Changed-Why:
 > Do you have revision 1.22 of filecomplete.c?
 > 
 > 
 > 

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44186 CVS commit: src/lib/libedit
Date: Mon, 6 Dec 2010 00:05:39 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Mon Dec  6 00:05:39 UTC 2010

 Modified Files:
 	src/lib/libedit: filecomplete.c

 Log Message:
 Improve previous to avoid changing the interface of an externally
 exposed function. (But note that this function is neither documented
 nor declared in any installed header file, and it probably should not
 be externally exposed.) Related to PR 44183, closes PR 44186.


 To generate a diff of this commit:
 cvs rdiff -u -r1.22 -r1.23 src/lib/libedit/filecomplete.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 06 Dec 2010 02:26:01 +0000
State-Changed-Why:
fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.