NetBSD Problem Report #55454

From www@netbsd.org  Fri Jul  3 17:59:48 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 DC8671A9217
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  3 Jul 2020 17:59:47 +0000 (UTC)
Message-Id: <20200703175946.F1B2A1A9218@mollari.NetBSD.org>
Date: Fri,  3 Jul 2020 17:59:46 +0000 (UTC)
From: jnaman806@gmail.com
Reply-To: jnaman806@gmail.com
To: gnats-bugs@NetBSD.org
Subject: wredrawln() in libcurses does not follow the sensible behaviour
X-Send-Pr-Version: www-1.0

>Number:         55454
>Category:       lib
>Synopsis:       wredrawln() in libcurses does not follow the sensible behaviour
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 03 18:00:00 +0000 2020
>Last-Modified:  Fri Jul 03 23:30:02 +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 behavior in case (beg_line + num_lines) exceeds LINES(win->maxy)
in xcurses/wredrawln
(https://pubs.opengroup.org/onlinepubs/7908799/xcurses/redrawwin.html).

Though not explicitly mentioned, I the sensible behavior is to only
mark the lines after beg_line till the end of the window. (ncurses
does this)

Current NetBSD curses implementation marks last num_lines,
i.e. [LINES-num_lines, LINES) in this case.

This change also makes sense as for a window with win->maxy = 5,
beg_line = 2 and num_lines = 8 gives segmentation fault, using the
proposed behavior not only we be more reasonable but also protecting
against the seg fault.

>How-To-Repeat:

>Fix:
There is a quick short fix to this. Instead of setting 
line = win->maxy - n; 
we should set
n = win->maxy - line;
https://github.com/NetBSD/src/blob/trunk/lib/libcurses/touchwin.c#L180

>Release-Note:

>Audit-Trail:

From: "Valeriy E. Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55454 CVS commit: src/lib/libcurses
Date: Fri, 3 Jul 2020 23:28:51 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Fri Jul  3 23:28:51 UTC 2020

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

 Log Message:
 wtouchln - verify/clip input parameters
 From Naman Jain in PR lib/55454


 To generate a diff of this commit:
 cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/touchwin.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.