NetBSD Problem Report #56243

From www@netbsd.org  Thu Jun 10 08:45:08 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_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 3D9D31A921F
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 10 Jun 2021 08:45:08 +0000 (UTC)
Message-Id: <20210610084506.CBA651A923B@mollari.NetBSD.org>
Date: Thu, 10 Jun 2021 08:45:06 +0000 (UTC)
From: mforney@mforney.org
Reply-To: mforney@mforney.org
To: gnats-bugs@NetBSD.org
Subject: libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position
X-Send-Pr-Version: www-1.0

>Number:         56243
>Category:       lib
>Synopsis:       libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    blymn
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 10 08:50:01 +0000 2021
>Last-Modified:  Wed Apr 27 22:05:01 +0000 2022
>Originator:     Michael Forney
>Release:        
>Organization:
>Environment:
>Description:
Consider the following test program:

#include <curses.h>

int main(void) {
	initscr();
	mvaddch(0, COLS - 1, 'X');
	mvaddch(0, 0, 'X');
	getch();
	endwin();
}

It should add an 'X' at the top-right and top-left cell. However, adding to the top-right sets the __ISPASTEOL flag for the first line, and this is not cleared during the wmove called from the subsequent mvaddch. When the second mvaddch calls _cursesi_addbyte, it increments the y position since __ISPASTEOL is set, so the 'X' is added at (1, 0) instead of (0, 0).

This bug can also be seen in the vis text editor, since it uses mvaddch to render its UI.
>How-To-Repeat:
1. Build libcurses with DISABLE_WCHAR=1
2. Compile the test program above.
3. Observe that 'X' is added at position (1, 0) instead of (0, 0).
>Fix:
I think that moving the cursor position should clear the __ISPASTEOL flag.

However, I don't know if it should be cleared from the line corresponding to the old y coordinate, the new y coordinate, or both. I'm also not sure why __ISPASTEOL is a per-line setting. Would it make more sense as a per-window setting, since it is a property of the window's cursor position?

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: lib-bug-people->blymn
Responsible-Changed-By: blymn@NetBSD.org
Responsible-Changed-When: Wed, 27 Apr 2022 07:28:13 +0000
Responsible-Changed-Why:
I will claim this bug.


From: "Brett Lymn" <blymn@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56243 CVS commit: src/lib/libcurses
Date: Wed, 27 Apr 2022 22:04:04 +0000

 Module Name:	src
 Committed By:	blymn
 Date:		Wed Apr 27 22:04:04 UTC 2022

 Modified Files:
 	src/lib/libcurses: move.c

 Log Message:
 Fix for PR 56243
 clear the past EOL flags when moving the cursor - they are no longer
 valid as move cannot put the cursor past the EOL.


 To generate a diff of this commit:
 cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.c

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

>Unformatted:

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.