Subject: pkg/24416: x11/fspanel crashes
To: None <gnats-bugs@gnats.NetBSD.org>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-bugs
Date: 02/13/2004 10:36:17
>Number:         24416
>Category:       pkg
>Synopsis:       x11/fspanel crashes
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 13 18:39:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Brian de Alwis
>Release:        NetBSD 1.6ZI
>Organization:
     Brian de Alwis | Graduate student | Software Practices Lab | UBC
"There is much pleasure to be gained in useless knowledge." - Bertrand Russell
>Environment:
	
	
System: NetBSD slab 1.6ZI NetBSD 1.6ZI (SLAB) #1: Thu Feb 5 22:59:07 PST 2004 bsd@slab:/home/scratch/src/sys/arch/i386/compile/SLAB i386
Architecture: i386
Machine: i386
>Description:
    These is a bug in one part of fspanel where it tries to determine
    the estimated width of a negatively sized string length.
>How-To-Repeat:
    The bug manifests itself in the following way.  I use fspanel on
    my i386 laptop.  I have it set up with 5 virtual terminals, and
    have the apm scripts set up to switch to Virtual Terminal 1 when
    being put to sleep.  When restored, it switches back to the previously
    active VT, and fspanel will have somehow crashed.  From looking
    at the code file, it occurs in some code that tries to determine how
    much of a string can be shown in a certain area.  When there is too
    little space, the length tried can go negative, causing Xft to
    crash.  I've attached a patch which changes this code to use a
    loop style as seen in the non-XFT code.

>Fix:
    --- fspanel.c.orig      2002-06-22 22:12:50.000000000 -0700
    +++ fspanel.c
    @@ -559,10 +559,10 @@ gui_draw_task (task *tk)

		    /* check how many chars can fit */
		    len = strlen (tk->name);
    -               while (1)
    +               while (len > 0)
		    {
			    XftTextExtents8 (dd, xfs, tk->name, len, &ext);
    -                       if (ext.width < taskw - (text_x - x) - 2 && len > 0)
    +                       if (ext.width < taskw - (text_x - x) - 2)
				    break;
			    len--;
		    }

>Release-Note:
>Audit-Trail:
>Unformatted: