NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/45739: top(1) segfaults on WINCH with unknown terminal



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 24 20:55:00 +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



Home | Main Index | Thread Index | Old Index