NetBSD Problem Report #45739

From mw@barfooze.de  Sat Dec 24 20:53:54 2011
Return-Path: <mw@barfooze.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 9E63663C457
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 24 Dec 2011 20:53:54 +0000 (UTC)
Message-Id: <E1ReYbK-000MiO-Gt@furnace.wzff.de>
Date: Sat, 24 Dec 2011 21:53:54 +0100
From: Moritz Wilhelmy <mw@barfooze.de>
Reply-To: mw@barfooze.de
To: gnats-bugs@gnats.NetBSD.org
Subject: top(1) segfaults on WINCH with unknown terminal
X-Send-Pr-Version: 3.95

>Number:         45739
>Category:       bin
>Synopsis:       top(1) segfaults on WINCH with unknown terminal
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 24 20:55:00 +0000 2011
>Closed-Date:    Sun Dec 25 00:46:37 +0000 2011
>Last-Modified:  Sun Dec 25 00:46:37 +0000 2011
>Originator:     Moritz Wilhelmy
>Release:        NetBSD 5.99.56
>Organization:
>Environment:
System: NetBSD fenrir 5.99.56 NetBSD 5.99.56 (GENERIC) #5: Thu Oct 20 11:47:51 CEST 2011 root@fenrir:/usr/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	tgoto(3) returns NULL if it doesn't know the terminal or the cm termcap setting is undefined.
	This NULL is then fed into strcpy as source.
>How-To-Repeat:
	TERM=blafasel top, resize the window immediately (on my machine, there is a short delay after starting top)
>Fix:
Index: screen.c
===================================================================
RCS file: /cvsroot/src/external/bsd/top/dist/screen.c,v
retrieving revision 1.3
diff -u -p -r1.3 screen.c
--- screen.c	5 May 2009 18:51:21 -0000	1.3
+++ screen.c	24 Dec 2011 18:16:26 -0000
@@ -167,6 +167,7 @@ void
 screen_getsize()

 {
+    char *t;

 #ifdef TIOCGWINSZ

@@ -203,8 +204,9 @@ screen_getsize()

 #endif /* TIOCGSIZE */
 #endif /* TIOCGWINSZ */
-
-    (void) strcpy(lower_left, tgoto(tc_cursor_motion, 0, screen_length - 1));
+	
+    if (t = tgoto(tc_cursor_motion, 0, screen_length - 1))
+	(void) strcpy(lower_left, t);
 }

 int

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45739 CVS commit: src/external/bsd/top/dist
Date: Sat, 24 Dec 2011 17:29:48 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sat Dec 24 22:29:48 UTC 2011

 Modified Files:
 	src/external/bsd/top/dist: screen.c

 Log Message:
 PR/45739: Moritz Wilhelmy: top(1) segfaults on WINCH with unknown terminal


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/external/bsd/top/dist/screen.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->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 24 Dec 2011 22:34:05 +0000
State-Changed-Why:
fixed?


From: Moritz Wilhelmy <mw@barfooze.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/45739 (top(1) segfaults on WINCH with unknown terminal)
Date: Sun, 25 Dec 2011 01:01:26 +0100

 Hello David,

 Yes, it's fixed.

 Thanks,

 Moritz

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 25 Dec 2011 00:46:37 +0000
State-Changed-Why:
Confirmed fixed, thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.