NetBSD Problem Report #54415

From  Sun Jul 28 01:40:01 2019
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 6ACDE7A158
	for <>; Sun, 28 Jul 2019 01:40:01 +0000 (UTC)
Message-Id: <>
Date: Sun, 28 Jul 2019 01:40:00 +0000 (UTC)
Subject: libedit stats completions for non-file completions
X-Send-Pr-Version: www-1.0

>Number:         54415
>Category:       lib
>Synopsis:       libedit stats completions for non-file completions
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 28 01:45:00 +0000 2019
>Last-Modified:  Sun Jul 28 09:30:01 +0000 2019
>Originator:     Ricky Zhou
>Release:        N/A
When libedit the list of available completions is displayed, each completion is treated as a file and statted.

The bug is that  fn_display_match_list in src/lib/libedit/filecomplete.c unconditionally calls append_char_function, ignoring the app_func argument that is overridden for readline.

Tangentially related bug: The max width passed into fn_display_match_list does not take the character appended by append_char_function into account. Because of this, tabular printing of completions can sometimes wrap. A fix might be to change:
	cols = (size_t)screenwidth / (width + 1);
	cols = (size_t)screenwidth / (width + 2);
to account for the appended char.
This bug was discovered in software using libedit on Linux. The software uses the readline compat layer and registers a custom completion function.

The statting was observed by stracing the software and pressing tab at a readline prompt to display completions.
The fix is to replace the call to append_char_function with app_func. The NULL check on app_func that falls back to append_char_function can probably also be removed, because fn_complete always passes an app_func.

From: "Christos Zoulas" <>
Subject: PR/54415 CVS commit: src/lib/libedit
Date: Sun, 28 Jul 2019 05:27:29 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sun Jul 28 09:27:29 UTC 2019

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

 Log Message:
 PR/54415: Ricky Zhou: libedit stats completions for non-file completions
 Use the proper completion function and account for the character appended
 by the function when computing the number of columns.

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

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

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.