diff options
Diffstat (limited to 'render/render.c')
-rw-r--r-- | render/render.c | 250 |
1 files changed, 77 insertions, 173 deletions
diff --git a/render/render.c b/render/render.c index 3a9d24a02..f03f54a2b 100644 --- a/render/render.c +++ b/render/render.c @@ -46,6 +46,7 @@ #include "glyphstr.h" #include <X11/Xfuncproto.h> #include "cursorstr.h" +#include "xace.h" #if HAVE_STDINT_H #include <stdint.h> @@ -212,18 +213,15 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { static void RenderResetProc (ExtensionEntry *extEntry); -#if 0 -static CARD8 RenderReqCode; -#endif int RenderErrBase; -int RenderClientPrivateIndex; +DevPrivateKey RenderClientPrivateKey; typedef struct _RenderClient { int major_version; int minor_version; } RenderClientRec, *RenderClientPtr; -#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr) +#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey)) static void RenderClientCallback (CallbackListPtr *list, @@ -247,9 +245,7 @@ RenderExtensionInit (void) return; if (!PictureFinishInit ()) return; - RenderClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (RenderClientPrivateIndex, - sizeof (RenderClientRec))) + if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec))) return; if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) return; @@ -259,17 +255,12 @@ RenderExtensionInit (void) RenderResetProc, StandardMinorOpcode); if (!extEntry) return; -#if 0 - RenderReqCode = (CARD8) extEntry->base; -#endif RenderErrBase = extEntry->errorBase; } static void RenderResetProc (ExtensionEntry *extEntry) { - ResetPicturePrivateIndex(); - ResetGlyphSetPrivateIndex(); } static int @@ -299,26 +290,6 @@ ProcRenderQueryVersion (ClientPtr client) return (client->noClientException); } -#if 0 -static int -VisualDepth (ScreenPtr pScreen, VisualPtr pVisual) -{ - DepthPtr pDepth; - int d, v; - - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = pScreen->allowedDepths + d; - for (v = 0; v < pDepth->numVids; v++) - { - if (pDepth->vids[v] == pVisual->vid) - return pDepth->depth; - } - } - return 0; -} -#endif - static VisualPtr findVisual (ScreenPtr pScreen, VisualID vid) { @@ -627,7 +598,7 @@ ProcRenderCreatePicture (ClientPtr client) LEGAL_NEW_RESOURCE(stuff->pid, client); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixWriteAccess); + DixReadAccess|DixAddAccess); if (rc != Success) return rc; @@ -668,7 +639,7 @@ ProcRenderChangePicture (ClientPtr client) int len; REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess, RenderErrBase + BadPicture); len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2); @@ -688,7 +659,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) int result; REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess, RenderErrBase + BadPicture); if (!pPicture->pDrawable) return BadDrawable; @@ -987,7 +958,7 @@ ProcRenderCreateGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; PictFormatPtr format; - int f; + int rc, f; REQUEST(xRenderCreateGlyphSetReq); REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); @@ -1026,6 +997,11 @@ ProcRenderCreateGlyphSet (ClientPtr client) glyphSet = AllocateGlyphSet (f, format); if (!glyphSet) return BadAlloc; + /* security creation/labeling check */ + rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType, + glyphSet, RT_NONE, NULL, DixCreateAccess); + if (rc != Success) + return rc; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) return BadAlloc; return Success; @@ -1035,20 +1011,19 @@ static int ProcRenderReferenceGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; + int rc; REQUEST(xRenderReferenceGlyphSetReq); REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->existing, - GlyphSetType, - DixWriteAccess); - if (!glyphSet) + rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType, + client, DixGetAttrAccess); + if (rc != Success) { client->errorValue = stuff->existing; - return RenderErrBase + BadGlyphSet; + return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } glyphSet->refcnt++; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) @@ -1063,17 +1038,16 @@ static int ProcRenderFreeGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; + int rc; REQUEST(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->glyphset, - GlyphSetType, - DixDestroyAccess); - if (!glyphSet) + rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + client, DixDestroyAccess); + if (rc != Success) { client->errorValue = stuff->glyphset; - return RenderErrBase + BadGlyphSet; + return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } FreeResource (stuff->glyphset, RT_NONE); return client->noClientException; @@ -1100,23 +1074,22 @@ ProcRenderAddGlyphs (ClientPtr client) xGlyphInfo *gi; CARD8 *bits; int size; - int err = BadAlloc; + int err; int i, screen; PicturePtr pSrc = NULL, pDst = NULL; PixmapPtr pSrcPix = NULL, pDstPix = NULL; CARD32 component_alpha; REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->glyphset, - GlyphSetType, - DixWriteAccess); - if (!glyphSet) + err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + client, DixAddAccess); + if (err != Success) { client->errorValue = stuff->glyphset; - return RenderErrBase + BadGlyphSet; + return (err == BadValue) ? RenderErrBase + BadGlyphSet : err; } + err = BadAlloc; nglyphs = stuff->nglyphs; if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec)) return BadAlloc; @@ -1203,7 +1176,7 @@ ProcRenderAddGlyphs (ClientPtr client) pDstPix = (pScreen->CreatePixmap) (pScreen, width, height, depth, - CREATE_PIMXAP_USAGE_GLYPH_PICTURE); + CREATE_PIXMAP_USAGE_GLYPH_PICTURE); GlyphPicture (glyph)[screen] = pDst = CreatePicture (0, &pDstPix->drawable, @@ -1286,19 +1259,17 @@ ProcRenderFreeGlyphs (ClientPtr client) { REQUEST(xRenderFreeGlyphsReq); GlyphSetPtr glyphSet; - int nglyph; + int rc, nglyph; CARD32 *gids; CARD32 glyph; REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->glyphset, - GlyphSetType, - DixWriteAccess); - if (!glyphSet) + rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + client, DixRemoveAccess); + if (rc != Success) { client->errorValue = stuff->glyphset; - return RenderErrBase + BadGlyphSet; + return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2; gids = (CARD32 *) (stuff + 1); @@ -1375,7 +1346,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, stuff->glyphset, GlyphSetType, - DixReadAccess); + DixUseAccess); if (!glyphSet) { client->errorValue = stuff->glyphset; @@ -1437,7 +1408,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, gs, GlyphSetType, - DixReadAccess); + DixUseAccess); if (!glyphSet) { client->errorValue = gs; @@ -1579,7 +1550,7 @@ ProcRenderCreateCursor (ClientPtr client) CursorMetricRec cm; CursorPtr pCursor; CARD32 twocolor[3]; - int ncolor; + int rc, ncolor; REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); @@ -1747,16 +1718,20 @@ ProcRenderCreateCursor (ClientPtr client) cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; - pCursor = AllocCursorARGB (srcbits, mskbits, argbbits, &cm, - GetColor(twocolor[0], 16), - GetColor(twocolor[0], 8), - GetColor(twocolor[0], 0), - GetColor(twocolor[1], 16), - GetColor(twocolor[1], 8), - GetColor(twocolor[1], 0)); - if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) - return (client->noClientException); - return BadAlloc; + rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm, + GetColor(twocolor[0], 16), + GetColor(twocolor[0], 8), + GetColor(twocolor[0], 0), + GetColor(twocolor[1], 16), + GetColor(twocolor[1], 8), + GetColor(twocolor[1], 0), + &pCursor, client, stuff->cid); + if (rc != Success) + return rc; + if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) + return BadAlloc; + + return client->noClientException; } static int @@ -1767,7 +1742,7 @@ ProcRenderSetPictureTransform (ClientPtr client) int result; REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess, RenderErrBase + BadPicture); result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform); if (client->noClientException != Success) @@ -1792,7 +1767,7 @@ ProcRenderQueryFilters (ClientPtr client) REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixGetAttrAccess); if (rc != Success) return rc; @@ -1897,7 +1872,7 @@ ProcRenderSetPictureFilter (ClientPtr client) char *name; REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess, RenderErrBase + BadPicture); name = (char *) (stuff + 1); params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3)); @@ -1941,7 +1916,8 @@ ProcRenderCreateAnimCursor (ClientPtr client) deltas[i] = elt->delay; elt++; } - ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor); + ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client, + stuff->cid); xfree (cursors); if (ret != Success) return ret; @@ -1987,6 +1963,11 @@ static int ProcRenderCreateSolidFill(ClientPtr client) pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error); if (!pPicture) return error; + /* security creation/labeling check */ + error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + pPicture, RT_NONE, NULL, DixCreateAccess); + if (error != Success) + return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; @@ -2016,6 +1997,11 @@ static int ProcRenderCreateLinearGradient (ClientPtr client) stuff->nStops, stops, colors, &error); if (!pPicture) return error; + /* security creation/labeling check */ + error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + pPicture, RT_NONE, NULL, DixCreateAccess); + if (error != Success) + return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; @@ -2046,6 +2032,11 @@ static int ProcRenderCreateRadialGradient (ClientPtr client) stuff->nStops, stops, colors, &error); if (!pPicture) return error; + /* security creation/labeling check */ + error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + pPicture, RT_NONE, NULL, DixCreateAccess); + if (error != Success) + return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; @@ -2075,6 +2066,11 @@ static int ProcRenderCreateConicalGradient (ClientPtr client) stuff->nStops, stops, colors, &error); if (!pPicture) return error; + /* security creation/labeling check */ + error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + pPicture, RT_NONE, NULL, DixCreateAccess); + if (error != Success) + return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; @@ -3225,98 +3221,6 @@ PanoramiXRenderTriFan(ClientPtr client) return result; } -#if 0 /* Not implemented yet */ - -static int -PanoramiXRenderColorTrapezoids(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrapezoidsReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq); - - if (extra_len && - (extra = (char *) xalloc (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client); - - if(result != Success) break; - } - - xfree(extra); - } - - return result; -} - -static int -PanoramiXRenderColorTriangles(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrianglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq); - - if (extra_len && - (extra = (char *) xalloc (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client); - - if(result != Success) break; - } - - xfree(extra); - } - - return result; -} - -#endif - static int PanoramiXRenderAddTraps (ClientPtr client) { |