summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2010-07-08 02:38:13 -0700
committerJamey Sharp <jamey@minilop.net>2010-09-13 15:55:17 -0700
commit2051e0f371de892b2e598b30c18dae96b58d68de (patch)
tree00686611384e3b266442ee7b631402e45c0db405 /dix
parentbbbf795e6b1ac048ea17164ba1089055cfe4306d (diff)
dixfonts: Deobfuscate GC ops calls.
Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Diffstat (limited to 'dix')
-rw-r--r--dix/dixfonts.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index e22eabe3a..ccb462794 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1170,6 +1170,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
FontPathElementPtr fpe;
GC *origGC = NULL;
+ int itemSize = c->reqType == X_PolyText8 ? 1 : 2;
if (client->clientGone)
{
@@ -1255,10 +1256,6 @@ doPolyText(ClientPtr client, PTclosurePtr c)
val.ptr = pFont;
ChangeGC(NullClient, c->pGC, GCFont, &val);
ValidateGC(c->pDraw, c->pGC);
- if (c->reqType == X_PolyText8)
- c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
- else
- c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
}
/* Undo the refcnt++ we performed when going to sleep */
@@ -1270,7 +1267,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
else /* print a string */
{
unsigned char *pNextElt;
- pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
+ pNextElt = c->pElt + TextEltHeader + (*c->pElt) * itemSize;
if ( pNextElt > c->endReq)
{
err = BadLength;
@@ -1283,7 +1280,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
}
if (c->pDraw)
{
- lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
+ lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, itemSize,
c->pElt + TextEltHeader);
}
else lgerr = Successful;
@@ -1381,8 +1378,12 @@ doPolyText(ClientPtr client, PTclosurePtr c)
if (c->pDraw)
{
c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
- c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, c->pElt + TextEltHeader);
+ if (c->reqType == X_PolyText8)
+ c->xorg = (* c->pGC->ops->PolyText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, (char *) (c->pElt + TextEltHeader));
+ else
+ c->xorg = (* c->pGC->ops->PolyText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, (unsigned short *) (c->pElt + TextEltHeader));
}
c->pElt = pNextElt;
}
@@ -1442,16 +1443,7 @@ PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
local_closure.pDraw = pDraw;
local_closure.xorg = xorg;
local_closure.yorg = yorg;
- if ((local_closure.reqType = reqType) == X_PolyText8)
- {
- local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
- local_closure.itemSize = 1;
- }
- else
- {
- local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16;
- local_closure.itemSize = 2;
- }
+ local_closure.reqType = reqType;
local_closure.pGC = pGC;
local_closure.did = did;
local_closure.err = Success;
@@ -1469,6 +1461,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
{
int err = Success, lgerr; /* err is in X error, not font error, space */
FontPathElementPtr fpe;
+ int itemSize = c->reqType == X_ImageText8 ? 1 : 2;
if (client->clientGone)
{
@@ -1493,7 +1486,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
}
}
- lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
+ lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, itemSize, c->data);
if (lgerr == Suspended)
{
if (!ClientIsAsleep(client)) {
@@ -1515,14 +1508,14 @@ doImageText(ClientPtr client, ITclosurePtr c)
*new_closure = *c;
c = new_closure;
- data = malloc(c->nChars * c->itemSize);
+ data = malloc(c->nChars * itemSize);
if (!data)
{
free(c);
err = BadAlloc;
goto bail;
}
- memmove(data, c->data, c->nChars * c->itemSize);
+ memmove(data, c->data, c->nChars * itemSize);
c->data = data;
pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
@@ -1562,8 +1555,12 @@ doImageText(ClientPtr client, ITclosurePtr c)
}
if (c->pDraw)
{
- (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, c->data);
+ if (c->reqType == X_ImageText8)
+ (* c->pGC->ops->ImageText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, (char *) c->data);
+ else
+ (* c->pGC->ops->ImageText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, (unsigned short *) c->data);
}
bail:
@@ -1601,16 +1598,7 @@ ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
local_closure.data = data;
local_closure.xorg = xorg;
local_closure.yorg = yorg;
- if ((local_closure.reqType = reqType) == X_ImageText8)
- {
- local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
- local_closure.itemSize = 1;
- }
- else
- {
- local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
- local_closure.itemSize = 2;
- }
+ local_closure.reqType = reqType;
local_closure.did = did;
(void) doImageText(client, &local_closure);