NetBSD Problem Report #55433
From www@netbsd.org Tue Jun 30 10:02:21 2020
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 9A4A11A9217
for <gnats-bugs@gnats.NetBSD.org>; Tue, 30 Jun 2020 10:02:21 +0000 (UTC)
Message-Id: <20200630100220.C80981A9218@mollari.NetBSD.org>
Date: Tue, 30 Jun 2020 10:02:20 +0000 (UTC)
From: jnaman806@gmail.com
Reply-To: jnaman806@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Bug in special character handling of ins_wstr() of libcurses
X-Send-Pr-Version: www-1.0
>Number: 55433
>Category: lib
>Synopsis: Bug in special character handling of ins_wstr() of libcurses
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: blymn
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 30 10:05:00 +0000 2020
>Closed-Date: Mon Nov 15 06:36:03 +0000 2021
>Last-Modified: Mon Nov 15 06:36:03 +0000 2021
>Originator: Naman Jain
>Release: NetBSD 9.0
>Organization:
IIT Kanpur
>Environment:
NetBSD localhost 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
int main() {
initscr();
wchar_t wstr[] = {'A', '\n', 'A', L'\0'};
ins_wstr(wstr);
refresh();
getch();
endwin();
return 0;
}
This code should result into 2 As, one at the start of first-line(0,0) and second at the start of second-line(1,0). Instead, it prints only a single A that too at (0,1).
Similarly, it shows unexpected behavior for \r also. For wstr[] = {'A', '\r', 'B', L'\0'}, the expected behaviour is a single B but it displays AB.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/55433: Bug in special character handling of ins_wstr() of
libcurses
Date: Thu, 16 Jul 2020 02:45:15 +0300
wins_nwstr - the worker function doesn't seem to handle special
character correctly in its first part as it computes wcwidth of the
whole argument.
As an aside, insstr() &c don't even pretend to try to handle special
characters.
-uwe
From: Brett Lymn <blymn@internode.on.net>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
jnaman806@gmail.com
Subject: Re: lib/55433: Bug in special character handling of ins_wstr() of
libcurses
Date: Fri, 17 Jul 2020 07:18:01 +0930
On Wed, Jul 15, 2020 at 11:50:02PM +0000, Valery Ushakov wrote:
>
> wins_nwstr - the worker function doesn't seem to handle special
> character correctly in its first part as it computes wcwidth of the
> whole argument.
>
> As an aside, insstr() &c don't even pretend to try to handle special
> characters.
>
They should according to SUS v2 so we should be doing it.
--
Brett Lymn
--
Sent from my NetBSD device.
"We are were wolves",
"You mean werewolves?",
"No we were wolves, now we are something else entirely",
"Oh"
Responsible-Changed-From-To: lib-bug-people->blymn
Responsible-Changed-By: blymn@NetBSD.org
Responsible-Changed-When: Mon, 25 Oct 2021 21:24:00 +0000
Responsible-Changed-Why:
I will claim this.
From: "Brett Lymn" <blymn@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55433 CVS commit: src/lib/libcurses
Date: Mon, 15 Nov 2021 06:27:06 +0000
Module Name: src
Committed By: blymn
Date: Mon Nov 15 06:27:06 UTC 2021
Modified Files:
src/lib/libcurses: ins_wstr.c
Log Message:
Fix for PR lib/55433
Correct the behaviour for ins_wstr:
* Properly check the string will fit by processing any special
characters present when preforming the check.
* Simplify the routine by removing code that duplicates the code in
_cursesi_addwchar and just call _cursesi_addwchar.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libcurses/ins_wstr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: blymn@NetBSD.org
State-Changed-When: Mon, 15 Nov 2021 06:36:03 +0000
State-Changed-Why:
Fixed with recent commit.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.