NetBSD Problem Report #37062

From martin@duskware.de  Fri Oct  5 13:20:49 2007
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id B0D6E63B8C2
	for <gnats-bugs@gnats.netbsd.org>; Fri,  5 Oct 2007 13:20:48 +0000 (UTC)
Message-Id: <20071005132003.EBBCE63B8C2@narn.NetBSD.org>
Date: Fri,  5 Oct 2007 13:20:03 +0000 (UTC)
From: shinden@linux.pl
Reply-To: shinden@linux.pl
To: netbsd-bugs-owner@NetBSD.org
Subject: hnb segvfaults with curses, doesn't look right
X-Send-Pr-Version: www-1.0

>Number:         37062
>Category:       pkg
>Synopsis:       hnb segvfaults with curses, doesn't look right
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 05 13:25:00 +0000 2007
>Closed-Date:    Mon Oct 19 18:46:25 +0000 2020
>Last-Modified:  Mon Oct 19 18:46:25 +0000 2020
>Originator:     Daniel Horecki
>Release:        current
>Organization:
>Environment:
NetBSD tatooine.stars 4.99.31 NetBSD 4.99.31 (TATOOINE) #0: Wed Oct  3 15:10:54 UTC 2007 root@tatooine.stars:/usr/obj/sys/arch/i386/compile/TATOOINE i386

>Description:
hnb is not compatible with curses library used with NetBSD. After pressing Escape it segvfaults. Included patch fixes that. 
>How-To-Repeat:
Build hnb, run and press enter.
>Fix:
This patch fixes it:

--- Makefile    7 Jan 2007 09:13:52 -0000       1.21
+++ Makefile    5 Oct 2007 13:19:32 -0000
@@ -10,7 +10,7 @@
 HOMEPAGE=      http://hnb.sourceforge.net/
 COMMENT=       Hierarchical data organizer

-INCOMPAT_CURSES=       NetBSD-1.5*-* NetBSD-1.6[-_.]*-* NetBSD-1.6[A-U]-*
+INCOMPAT_CURSES=       NetBSD-*

 USE_TOOLS+=            gmake


>Release-Note:

>Audit-Trail:
From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: jdc@NetBSD.org
Subject: Re: pkg/37062: hnb segvfaults with curses, doesn't look right
Date: Thu, 18 Oct 2007 10:27:38 +0100

 > hnb is not compatible with curses library used with NetBSD. After pressing
 > Escape it segvfaults. Included patch fixes that.

 The former looks like a bug in hnb.  The curses keyname() function is
 allowed to return NULL and hnb doesn't check for this.  However, ncurses
 returns "-1" for keyname(-1), which is what hnb does here.

 The appended patch makes NetBSD curses compatible with ncurses (and
 incompatible with Solaris' curses) and also updates keyname() and
 key_name() to use static space (otherwise applications will leak a small
 amount of memory each time they call keyname() or key_name().  I will
 probably commit this, as more applications are written to ncurses than
 the curses standard.

 The latter problem of the hnb display may well be a NetBSD curses bug -
 I'll investigate further.

 J

   - - 8< - - - - - - - - - - - - - Cut here - - - - - - - - - - - - - >8 - -
 diff -ur /usr/src/lib/libcurses/curses_keyname.3 ./curses_keyname.3
 --- /usr/src/lib/libcurses/curses_keyname.3	2004-03-21 11:21:19.000000000 +0000
 +++ ./curses_keyname.3	2007-10-17 13:22:00.000000000 +0100
 @@ -28,7 +28,7 @@
  .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  .\" POSSIBILITY OF SUCH DAMAGE.
  .\"
 -.Dd June 13, 2003
 +.Dd October 17, 2007
  .Dt CURSES_KEYNAME 3
  .Os
  .Sh NAME
 @@ -57,9 +57,14 @@
  .It Li "Meta + visible character" Ta "159 - 254" Ta "M-X"
  .It Li "Meta + delete character" Ta "255" Ta "M-^?"
  .It Li "Named key" Ta "KEY_MIN - KEY_MAX" Ta "KEY_EXIT"
 +.It Li "Unknown key" Ta "" Ta "-1"
  .El
  .Sh SEE ALSO
  .Xr curses_input 3
 +.Sh NOTE
 +The return value of
 +.Fn keyname
 +is a static buffer, which will be overwritten on a subsequent call.
  .Sh STANDARDS
  The
  .Nx
 diff -ur /usr/src/lib/libcurses/keyname.c ./keyname.c
 --- /usr/src/lib/libcurses/keyname.c	2007-08-04 09:36:49.000000000 +0100
 +++ ./keyname.c	2007-10-17 12:17:04.000000000 +0100
 @@ -48,6 +48,8 @@
  #include "curses_private.h"

  #define KEYNAMEMAX (size_t) 14	/* "KEY_BACKSPACE\0" */
 +static char name[KEYNAMEMAX + 1];
 +
  /*
   * keyname --
   *	Return name of key or NULL;
 @@ -57,19 +59,19 @@
  {
  /* We don't bother with the large keyname table if SMALL is defined. */
  #ifdef SMALL
 -	return NULL;
 +	strcpy(name, "-1\0");
 +	return name;
  #else
 -	char *name;
 -
 -	if (key < 0)
 -		return NULL;
 +	if (key < 0) {
 +		strcpy(name, "-1\0");
 +		return name;
 +	}

  	/* No name. */
 -	if (key == 0x100)
 -		return NULL;
 -
 -	if ((name = malloc(KEYNAMEMAX + 1)) == NULL)
 -		return NULL;
 +	if (key == 0x100) {
 +		strcpy(name, "-1\0");
 +		return name;
 +	}

  	/* Control codes */
  	if (key < 0x20) {
 @@ -500,20 +502,14 @@
  #ifndef HAVE_WCHAR
  	return NULL;
  #else
 -/* We don't bother with the large keyname table if SMALL is defined. */
 -#ifdef SMALL
 -	return NULL;
 -#else
 -	char *name = keyname(( int )key );
 +	(void) keyname((int) key);

 -	if ( !name )
 -		return NULL;
 -	if (!strncmp( name, "M-", 2 )) {
 -		free( name );
 -		name = NULL;
 +	if (!strncmp(name, "M-", 2)) {
 +		/* Remove the "M-" */
 +		name[0] = name[2];
 +		name[1] = '\0';
  	}
  	return name;
 -#endif
  #endif /* HAVE_WCHAR */
  }

   - - 8< - - - - - - - - - - - - - Cut here - - - - - - - - - - - - - >8 - -
 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/37062 CVS commit: src/lib/libcurses
Date: Thu, 25 Oct 2007 20:32:40 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Thu Oct 25 20:32:40 UTC 2007

 Modified Files:
 	src/lib/libcurses: curses_keyname.3 keyname.c

 Log Message:
 Return "-1" for unknown keys and only return NULL for errors.

 Make the key name string a static buffer.  The specification allows this,
 so the previous behaviour would leak a small amount of memory, as the
 application wouldn't free the returned string.

 Fixes one part of PR pkg/37062.


 To generate a diff of this commit:
 cvs rdiff -r1.3 -r1.4 src/lib/libcurses/curses_keyname.3
 cvs rdiff -r1.4 -r1.5 src/lib/libcurses/keyname.c

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

From: Sergey Svishchev <svs@ropnet.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/37062
Date: Mon, 21 Mar 2011 21:27:56 +0300

 Can you describe (or provide a screenshot of) hnb that doesn't "look right"?

 -- 
 Sergey Svishchev

From: Daniel Horecki <shinden@linux.pl>
To: gnats-bugs@NetBSD.org
Cc: svs@ropnet.ru, pkg-manager@netbsd.org, gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Subject: Re: pkg/37062
Date: Tue, 22 Mar 2011 00:30:56 +0100

 On Mon, 21 Mar 2011 18:50:03 +0000 (UTC)
 Sergey Svishchev <svs@ropnet.ru> wrote:

 > The following reply was made to PR pkg/37062; it has been noted by
 > GNATS.
 > 
 > From: Sergey Svishchev <svs@ropnet.ru>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: pkg/37062
 > Date: Mon, 21 Mar 2011 21:27:56 +0300
 > 
 >  Can you describe (or provide a screenshot of) hnb that doesn't "look
 > right"? 
 >  -- 
 >  Sergey Svishchev
 >  
 > 

 with netbsd's curses:
 http://morr.pl/netbsd/2011-03-22-002154_1024x768_scrot.png
 http://morr.pl/netbsd/2011-03-22-002339_1024x768_scrot.png

 with ncurses:
 http://morr.pl/netbsd/2011-03-22-002253_1024x768_scrot.png
 http://morr.pl/netbsd/2011-03-22-002440_1024x768_scrot.png

 (first screenshots shows main program, second menu)

 -- 
 Daniel Horecki
 http://morr.pl http://linux.pl http://netbsd.pl http://netbsd.org
 HAIL ERIS!

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 17 Sep 2018 11:40:27 +0000
State-Changed-Why:
What would you like to do with the remainder of this bug report? hnb the package now defaults to ncurses. it crashes whether it uses ncurses or curses with a segfault for me. We can assign this to be a lib bug if you want more fixes to netbsd curses.


State-Changed-From-To: feedback->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Mon, 19 Oct 2020 18:46:25 +0000
State-Changed-Why:
feedback timeout, original problem is most ly fixed


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