NetBSD Problem Report #54415

From www@netbsd.org  Sun Jul 28 01:40:01 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6ACDE7A158
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 28 Jul 2019 01:40:01 +0000 (UTC)
Message-Id: <20190728014000.83B9C7A1D3@mollari.NetBSD.org>
Date: Sun, 28 Jul 2019 01:40:00 +0000 (UTC)
From: ricky@rzhou.org
Reply-To: ricky@rzhou.org
To: gnats-bugs@NetBSD.org
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
>Organization:
>Environment:
N/A
>Description:
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);
to
	cols = (size_t)screenwidth / (width + 2);
to account for the appended char.
>How-To-Repeat:
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.
>Fix:
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.

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
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: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.