NetBSD Problem Report #55474

From www@netbsd.org  Thu Jul  9 20:12:14 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 829C91A9213
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  9 Jul 2020 20:12:14 +0000 (UTC)
Message-Id: <20200709201213.A10141A921A@mollari.NetBSD.org>
Date: Thu,  9 Jul 2020 20:12:13 +0000 (UTC)
From: jnaman806@gmail.com
Reply-To: jnaman806@gmail.com
To: gnats-bugs@NetBSD.org
Subject: wattroff unsets all attributes if passed STANDOUT as argument
X-Send-Pr-Version: www-1.0

>Number:         55474
>Category:       lib
>Synopsis:       wattroff unsets all attributes if passed STANDOUT as argument
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 09 20:15:00 +0000 2020
>Last-Modified:  Thu Jul 09 21:55:01 +0000 2020
>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:
The attroff() and wattroff() functions turn off attrs in the current or specified window "without affecting any others".

But if passed STANDOUT (1<<8) as an argument, it turns off all attributes. This is because of usage of wstandend() in line#468 https://github.com/NetBSD/src/blob/161821ccfdc43542c5d7b008a4057f0bcea38217/lib/libcurses/attributes.c#L468 .

wstandend() unsets all the attributes.
>How-To-Repeat:

>Fix:
Use win->wattr &= ~A_STANDOUT;
And why not for underline also? Though for underline both ways will work.

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/55474: wattroff unsets all attributes if passed STANDOUT as
 argument
Date: Fri, 10 Jul 2020 00:54:19 +0300

 On Thu, Jul 09, 2020 at 20:15:00 +0000, jnaman806@gmail.com wrote:

 > The attroff() and wattroff() functions turn off attrs in the current
 > or specified window "without affecting any others".
 > 
 > But if passed STANDOUT (1<<8) as an argument, it turns off all
 > attributes. This is because of usage of wstandend() in line#468
 > https://github.com/NetBSD/src/blob/161821ccfdc43542c5d7b008a4057f0bcea38217/lib/libcurses/attributes.c#L468 .
 > 
 > wstandend() unsets all the attributes.

 I've noticed this problem when I was refactoring this code a while
 back, but ultimately decided to leave it as it is.

 The standard is somewhat unclear. It says that "the standend() and
 wstandend() functions turn off all attributes of the current or
 specified window."  Now, should attroff(A_STANDOUT) be equivalent to
 standend()?  Yes, for attroff() there is that passage about "without
 affecting any others", but it is kinda false for A_STANDOUT by
 construction, as standout is not a separate attribute but an alias for
 the "best highlighting mode of the terminal".  So using A_STANDOUT
 combined with anything is already a rather dubious thing to do.

 To fix this properly (for some values of "fix" and "properly") we
 should switch refresh code to use sgr directly I think.

 -uwe

NetBSD Home
NetBSD PR Database Search

(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.