From 3051ba20af89c12c489e91c71d04df0bb8afb7ac Mon Sep 17 00:00:00 2001 From: jenglish Date: Sun, 28 Nov 2004 19:00:37 +0000 Subject: Tk_DrawChars: Check for short integer overflow in x,y coordinates [Fixes: #942320 "Tk, Xft, text and long lines"] --- ChangeLog | 4 ++++ unix/tkUnixRFont.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e265764..fa30183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-11-28 Joe English + * unix/tkUnixRFont.c(Tk_DrawChars): Check for short integer overflow + in x,y coordinates [Fixes: #942320 "Tk, Xft, text and long lines"] + 2004-11-26 David Gravereaux * win/makefile.vc: Shell targets needed more stack space. diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index fdf9ebd..2557ab0 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixRFont.c,v 1.7 2004/10/08 16:16:54 jenglish Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.8 2004/11/28 19:00:49 jenglish Exp $ */ #include "tkUnixInt.h" @@ -586,6 +586,7 @@ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y) int x, y; /* Coordinates at which to place origin of * string when drawing. */ { + const int maxCoord = 0x7FFF; /* Xft coordinates are 16 bit values */ UnixFtFont *fontPtr = (UnixFtFont *) tkfont; XGCValues values; XColor xcolor; @@ -623,7 +624,7 @@ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y) fontPtr->color.pixel = values.foreground; } nspec = 0; - while (numBytes > 0) { + while (numBytes > 0 && x <= maxCoord && y <= maxCoord) { XftFont *ftFont; FcChar32 c; @@ -641,7 +642,6 @@ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y) specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c); specs[nspec].x = x; specs[nspec].y = y; - XftGlyphExtents(fontPtr->display, ftFont, &specs[nspec].glyph, 1, &metrics); x += metrics.xOff; -- cgit v0.12