Debian Bug report logs - #287360
tk8.4: segfaults because it can't handle some X font aliases

version graph

Package: tk8.4; Maintainer for tk8.4 is Debian Tcl/Tk Packagers <pkg-tcltk-devel@lists.alioth.debian.org>; Source for tk8.4 is src:tk8.4 (PTS, buildd, popcon).

Reported by: Takahide HIGUCHI <h2@hima.jp>

Date: Mon, 27 Dec 2004 11:18:01 UTC

Severity: important

Found in version 8.4.7-1

Fixed in version tk8.4/8.4.15-1

Done: Sergei Golovan <sgolovan@nes.ru>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Takahide HIGUCHI <h2@hima.jp>, Chris Waters <xtifr@debian.org>:
Bug#287360; Package tk8.4. (full text, mbox, link).


Acknowledgement sent to Takahide HIGUCHI <h2@hima.jp>:
New Bug report received and forwarded. Copy sent to Takahide HIGUCHI <h2@hima.jp>, Chris Waters <xtifr@debian.org>. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Takahide HIGUCHI <h2@hima.jp>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: tk8.4: segfaults because it can't handle some X font aliases
Date: Mon, 27 Dec 2004 20:01:21 +0900 (JST)
Package: tk8.4
Version: 8.4.7-1
Severity: important

How to reproduce: 

1. install 'xfonts-mplus' and 'xmaxima' package

2. run 'xmaxima' command. It will result segmentation fault.

   I also confirmed that a test program in the tk8.4 source
   (tests/unixFont.test) fails.
   


Details of the bug:

The font aliases of the X window system, which can be very short string.
My output of xlsfonts command contains like following:

...
mplus_f12r           
mplus_f12r
...
naga10
naga10b
...
a12
k12
...


TkpGetFontFamilies() function in tk8.4 source assumes that font names
are always in the form of XLFD (X Logical Font Description), such as:

     '-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1'
     '-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1'

Hence TkpGetFontFamilies() function will fail to parse font aliases 
which does not contain two '-' characters.


Proposed patch: 

Following patch makes tk8.4 not to assume there is a font family 
in given font name or font aliase.


diff -ruN tk8.4-8.4.7.original/unix/tkUnixFont.c tk8.4-8.4.7/unix/tkUnixFont.c
--- tk8.4-8.4.7.original/unix/tkUnixFont.c	2003-10-29 10:07:46.000000000 +0900
+++ tk8.4-8.4.7/unix/tkUnixFont.c	2004-12-27 19:09:44.000000000 +0900
@@ -839,6 +839,7 @@
 {
     int i, new, numNames;
     char *family;
+    char *family_endp;
     Tcl_HashTable familyTable;
     Tcl_HashEntry *hPtr;
     Tcl_HashSearch search;
@@ -850,9 +851,14 @@
     Tcl_InitHashTable(&familyTable, TCL_STRING_KEYS);
     nameList = ListFonts(Tk_Display(tkwin), "*", &numNames);
     for (i = 0; i < numNames; i++) {
-	family = strchr(nameList[i] + 1, '-') + 1;
-	strchr(family, '-')[0] = '\0';
-	Tcl_CreateHashEntry(&familyTable, family, &new);
+	family = strchr(nameList[i] + 1, '-');
+	if(family) {
+	  family_endp = strchr(family + 1, '-');
+	  if(family_endp) {
+	    family_endp[0] = '\0';
+	    Tcl_CreateHashEntry(&familyTable, family, &new);
+	  }
+	}
     }
     XFreeFontNames(nameList);
 



-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.9
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages tk8.4 depends on:
ii  libc6                     2.3.2.ds1-18   GNU C Library: Shared libraries an
ii  libx11-6                  4.3.0.dfsg.1-8 X Window System protocol client li
ii  tcl8.4                    8.4.7-1        Tcl (the Tool Command Language) v8
ii  xlibs                     4.3.0.dfsg.1-8 X Window System client libraries m

-- no debconf information



Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#287360; Package tk8.4. (full text, mbox, link).


Acknowledgement sent to Chris Waters <xtifr@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #10 received at 287360@bugs.debian.org (full text, mbox, reply):

From: Chris Waters <xtifr@debian.org>
To: Takahide HIGUCHI <h2@hima.jp>, 287360@bugs.debian.org
Subject: Re: Bug#287360: tk8.4: segfaults because it can't handle some X font aliases
Date: Wed, 29 Dec 2004 00:50:44 -0800
On Mon, Dec 27, 2004 at 08:01:21PM +0900, Takahide HIGUCHI wrote:

> The font aliases of the X window system, which can be very short string.
[...]

> TkpGetFontFamilies() function in tk8.4 source assumes that font names
> are always in the form of XLFD (X Logical Font Description)

Hmm, that's very strange.  Even a bare-bones installation of X
contains font aliases such as "fixed" and "olglyph-10".  Do you have
any idea why *those* don't cause a crash?

Nevertheless, your patch looks simple and sensible, and I'm certainly
willing to apply it.  Look for a new upload soon.  Thanks very much.

-- 
Chris Waters           |  Pneumonoultra-        osis is too long
xtifr@debian.org       |  microscopicsilico-    to fit into a single
or xtifr@speakeasy.net |  volcaniconi-          standalone haiku



Reply sent to Sergei Golovan <sgolovan@nes.ru>:
You have taken responsibility. (Sun, 30 Aug 2009 16:36:18 GMT) (full text, mbox, link).


Notification sent to Takahide HIGUCHI <h2@hima.jp>:
Bug acknowledged by developer. (Sun, 30 Aug 2009 16:36:18 GMT) (full text, mbox, link).


Message #15 received at 287360-close@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@nes.ru>
To: 287360-close@bugs.debian.org
Subject: The similar patch is applied already
Date: Sun, 30 Aug 2009 20:30:52 +0400
Version: 8.4.14-1

The similar patch was applied between 8.4.12 and 8.4.14, so I'm closing the bug.

Cheers!
-- 
Sergei Golovan




No longer marked as fixed in versions 8.4.14-1. Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Fri, 01 Nov 2013 01:21:24 GMT) (full text, mbox, link).


Marked as fixed in versions tk8.4/8.4.15-1. Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Fri, 01 Nov 2013 01:21:25 GMT) (full text, mbox, link).


Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Fri, 29 Nov 2013 07:40:06 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Oct 11 00:26:06 2017; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.