bugfixes

  • From: Tommy Pettersson <ptp@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Fri, 24 Sep 2004 15:38:20 +0200

Hi list,

Is anyone still using wily, or has everyone switched to
acme now?

Anyhow, here are two bugfixes for 9libs-1.0 (but the same
problem exists in wily-0.13.41, with the same fix):

The first bug is for xfonts that have the whole range
from 0x0000 to 0xffff of chars.  struct Subfont uses data
type short.  On at least i386 short is only 16 bits, so
XFontStructtoSubfont() will wrongly calculate the font to
have zero chars in the range from 0 to -1.  The info array
will then not be correctly constructed.

The second bug happens when the user specifies a bigger range
in the Plan 9 font file then the real xfont actually has.
For example,

  0x0000 0xffff -some-font-in-iso10646-1

This -some-font- may not agree on the size of this range;
it might have only 0x0000 to 0x2fff (xfd will show this),
and then the info array in struct Subfont will have only
0x3001 entries.  But when the array is used, there is no
upper bound check on the index, other then for choosing the
subfont in question, and it is assumed to contain the whole
range as specified by the user.


-- 
Tommy Pettersson <ptp@xxxxxxxxxxxxxx>



diff -ur 9libs-1.0.orig/include/libg.h 9libs-1.0.new/include/libg.h
--- 9libs-1.0.orig/include/libg.h       Tue Aug 11 02:20:32 1998
+++ 9libs-1.0.new/include/libg.h        Fri Sep 24 14:56:57 2004
@@ -92,12 +92,12 @@
 
 struct Subfont
 {
-       short           minrow; /* first character row in font (for X subfonts) 
*/
-       short           mincol; /* first character col in font (for X subfonts) 
*/
-       short           minchar; /* first char code in subfont */
-       short           maxchar; /* last char code in subfont */
-       short           width;  /* number of chars in row */
-       short           n;      /* number of chars in font */
+       int             minrow; /* first character row in font (for X subfonts) 
*/
+       int             mincol; /* first character col in font (for X subfonts) 
*/
+       int             minchar; /* first char code in subfont */
+       int             maxchar; /* last char code in subfont */
+       int             width;  /* number of chars in row */
+       int             n;      /* number of chars in font */
        unsigned char   height; /* height of bitmap */
        char            ascent; /* top of bitmap to baseline */
        Fontchar        *info;  /* n+1 character descriptors */
diff -ur 9libs-1.0.orig/libXg/font.c 9libs-1.0.new/libXg/font.c
--- 9libs-1.0.orig/libXg/font.c Tue Aug 11 01:51:34 1998
+++ 9libs-1.0.new/libXg/font.c  Fri Sep 24 14:56:57 2004
@@ -25,7 +25,7 @@
                                sf = csf->f;
                                c = rx-csf->min+sf->minchar;
                                c = 
((c>>8)-sf->minrow)*sf->width+(c&0xff)-sf->mincol;
-                               if (c < 0)
+                               if ((c < 0) || (c >= sf->n))
                                        break;
                                        /* ignore zero width characters */
                                if (sf->info[c].cwidth == 0 && 
sf->info[c].width == 0)


Other related posts: