summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/animcur.c32
-rw-r--r--render/glyph.c323
-rw-r--r--render/glyphstr.h43
-rw-r--r--render/mirect.c2
-rw-r--r--render/picture.c149
-rw-r--r--render/picturestr.h44
-rw-r--r--render/render.c220
7 files changed, 249 insertions, 564 deletions
diff --git a/render/animcur.c b/render/animcur.c
index 1f25e79d0..125928931 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -44,6 +44,7 @@
#include "dixfontstr.h"
#include "opaque.h"
#include "picturestr.h"
+#include "xace.h"
typedef struct _AnimCurElt {
CursorPtr pCursor; /* cursor to show */
@@ -87,14 +88,14 @@ static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateIndex = -1;
static int AnimCurGeneration;
+static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKey;
#define IsAnimCur(c) ((c)->bits == &animCursorBits)
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
-#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
-#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (pointer) (p))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
+#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
+#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -128,8 +129,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
SetAnimCurScreen(pScreen,0);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (as);
- if (index == 0)
- AnimCurScreenPrivateIndex = -1;
return ret;
}
@@ -324,9 +323,6 @@ AnimCurInit (ScreenPtr pScreen)
if (AnimCurGeneration != serverGeneration)
{
- AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (AnimCurScreenPrivateIndex < 0)
- return FALSE;
AnimCurGeneration = serverGeneration;
animCurState.pCursor = 0;
animCurState.pScreen = 0;
@@ -351,10 +347,10 @@ AnimCurInit (ScreenPtr pScreen)
}
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor)
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
{
CursorPtr pCursor;
- int i;
+ int rc, i;
AnimCurPtr ac;
for (i = 0; i < screenInfo.numScreens; i++)
@@ -371,7 +367,6 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
if (!pCursor)
return BadAlloc;
pCursor->bits = &animCursorBits;
- animCursorBits.refcnt++;
pCursor->refcnt = 1;
pCursor->foreRed = cursors[0]->foreRed;
@@ -382,9 +377,22 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
pCursor->backGreen = cursors[0]->backGreen;
pCursor->backBlue = cursors[0]->backBlue;
+ pCursor->id = cid;
+ pCursor->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
+ RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ dixFreePrivates(pCursor->devPrivates);
+ xfree(pCursor);
+ return rc;
+ }
+
/*
* Fill in the AnimCurRec
*/
+ animCursorBits.refcnt++;
ac = GetAnimCur (pCursor);
ac->nelt = ncursor;
ac->elts = (AnimCurElt *) (ac + 1);
diff --git a/render/glyph.c b/render/glyph.c
index e1dc0bc99..286e39d63 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -85,220 +85,19 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static int globalTotalGlyphPrivateSize = 0;
-
-static int glyphPrivateCount = 0;
-
-void
-ResetGlyphPrivates (void)
-{
- glyphPrivateCount = 0;
-}
-
-int
-AllocateGlyphPrivateIndex (void)
-{
- return glyphPrivateCount++;
-}
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount)
-{
- PictureScreenPtr ps;
- unsigned oldamount;
-
- ps = GetPictureScreenIfSet (pScreen);
- if (!ps)
- return FALSE;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) *
- sizeof (DevUnion);
-
- if (index2 >= ps->glyphPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *) xrealloc (ps->glyphPrivateSizes,
- (index2 + 1) * sizeof (unsigned));
- if (!nsizes)
- return FALSE;
-
- while (ps->glyphPrivateLen <= index2)
- {
- nsizes[ps->glyphPrivateLen++] = 0;
- ps->totalGlyphPrivateSize += sizeof (DevUnion);
- }
- ps->glyphPrivateSizes = nsizes;
- }
- oldamount = ps->glyphPrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->glyphPrivateSizes[index2] = amount;
- ps->totalGlyphPrivateSize += (amount - oldamount);
- }
- ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8);
-
- return TRUE;
-}
-
static void
-SetGlyphScreenPrivateOffsets (void)
+FreeGlyphPrivates (GlyphPtr glyph)
{
- PictureScreenPtr ps;
- int offset = 0;
- int i;
+ ScreenPtr pScreen;
+ int i;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ps->glyphPrivateOffset = offset;
- offset += ps->totalGlyphPrivateSize / sizeof (DevUnion);
- }
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ dixFreePrivates(*GetGlyphPrivatesForScreen(glyph, pScreen));
}
-}
-static void
-SetGlyphPrivatePointers (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- int i;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int len;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ppriv = glyph->devPrivates + ps->glyphPrivateOffset;
- sizes = ps->glyphPrivateSizes;
- ptr = (char *) (ppriv + ps->glyphPrivateLen);
- for (len = ps->glyphPrivateLen; --len >= 0; ppriv++, sizes++)
- {
- if ((size = *sizes) != 0)
- {
- ppriv->ptr = (pointer) ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer) 0;
- }
- }
- }
-}
-
-static Bool
-ReallocGlobalGlyphPrivate (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- DevUnion *devPrivates;
- char *ptr;
- int i;
-
- devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!devPrivates)
- return FALSE;
-
- ptr = (char *) devPrivates;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- if (ps->glyphPrivateOffset != -1)
- {
- memcpy (ptr, glyph->devPrivates + ps->glyphPrivateOffset,
- ps->totalGlyphPrivateSize);
- }
- else if (ps->totalGlyphPrivateSize)
- {
- memset (ptr, 0, ps->totalGlyphPrivateSize);
- }
-
- ptr += ps->totalGlyphPrivateSize;
- }
- }
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
-
- glyph->devPrivates = devPrivates;
-
- return TRUE;
-}
-
-Bool
-GlyphInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- ps->totalGlyphPrivateSize = 0;
- ps->glyphPrivateSizes = 0;
- ps->glyphPrivateLen = 0;
- ps->glyphPrivateOffset = -1;
-
- return TRUE;
-}
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- if (ps->totalGlyphPrivateSize)
- {
- GlyphPtr glyph;
- int fdepth, i;
-
- globalTotalGlyphPrivateSize += ps->totalGlyphPrivateSize;
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return FALSE;
- }
- }
- }
-
- SetGlyphScreenPrivateOffsets ();
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- SetGlyphPrivatePointers (glyph);
-
- if (!(*ps->RealizeGlyph) (pScreen, glyph))
- return FALSE;
- }
- }
- }
- }
- else
- ps->glyphPrivateOffset = 0;
-
- return TRUE;
+ dixFreePrivates(glyph->devPrivates);
+ glyph->devPrivates = NULL;
}
void
@@ -308,8 +107,6 @@ GlyphUninit (ScreenPtr pScreen)
GlyphPtr glyph;
int fdepth, i;
- globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize;
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
@@ -321,43 +118,19 @@ GlyphUninit (ScreenPtr pScreen)
if (glyph && glyph != DeletedGlyph)
{
(*ps->UnrealizeGlyph) (pScreen, glyph);
-
- if (globalTotalGlyphPrivateSize)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return;
- }
- else
- {
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
- glyph->devPrivates = NULL;
- }
+ FreeGlyphPrivates(glyph);
}
}
}
- if (globalTotalGlyphPrivateSize)
- SetGlyphScreenPrivateOffsets ();
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
continue;
for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (globalTotalGlyphPrivateSize)
- SetGlyphPrivatePointers (glyph);
- }
- }
}
-
- if (ps->glyphPrivateSizes)
- xfree (ps->glyphPrivateSizes);
}
GlyphHashSetPtr
@@ -371,50 +144,6 @@ FindGlyphHashSet (CARD32 filled)
return 0;
}
-static int _GlyphSetPrivateAllocateIndex = 0;
-
-int
-AllocateGlyphSetPrivateIndex (void)
-{
- return _GlyphSetPrivateAllocateIndex++;
-}
-
-void
-ResetGlyphSetPrivateIndex (void)
-{
- _GlyphSetPrivateAllocateIndex = 0;
-}
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr)
-{
- pointer *new;
-
- if (n > glyphSet->maxPrivate) {
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1])) {
- new = (pointer *) xrealloc (glyphSet->devPrivates,
- (n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- } else {
- new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- if (glyphSet->devPrivates)
- memcpy (new,
- glyphSet->devPrivates,
- (glyphSet->maxPrivate + 1) * sizeof (pointer));
- }
- glyphSet->devPrivates = new;
- /* Zero out new, uninitialize privates */
- while (++glyphSet->maxPrivate < n)
- glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0;
- }
- glyphSet->devPrivates[n] = ptr;
- return TRUE;
-}
-
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash,
CARD32 signature,
@@ -582,8 +311,7 @@ FreeGlyph (GlyphPtr glyph, int format)
(*ps->UnrealizeGlyph) (pScreen, glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
}
}
@@ -610,8 +338,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
glyph = gr->glyph;
}
@@ -678,16 +405,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
-
- if (globalTotalGlyphPrivateSize)
- {
- glyph->devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!glyph->devPrivates)
- return 0;
-
- SetGlyphPrivatePointers (glyph);
- } else
- glyph->devPrivates = NULL;
+ glyph->devPrivates = NULL;
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -709,9 +427,8 @@ bail:
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+
+ FreeGlyphPrivates(glyph);
xfree (glyph);
return 0;
}
@@ -790,15 +507,11 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
return FALSE;
}
- size = (sizeof (GlyphSetRec) +
- (sizeof (pointer) * _GlyphSetPrivateAllocateIndex));
+ size = sizeof (GlyphSetRec);
glyphSet = xalloc (size);
if (!glyphSet)
return FALSE;
bzero((char *)glyphSet, size);
- glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
- if (_GlyphSetPrivateAllocateIndex)
- glyphSet->devPrivates = (pointer)(&glyphSet[1]);
if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
{
@@ -838,11 +551,7 @@ FreeGlyphSet (pointer value,
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
xfree (table);
-
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1]))
- xfree(glyphSet->devPrivates);
-
+ dixFreePrivates(glyphSet->devPrivates);
xfree (glyphSet);
}
return Success;
diff --git a/render/glyphstr.h b/render/glyphstr.h
index c6ab5aa11..67b21fe63 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -30,6 +30,7 @@
#include "screenint.h"
#include "regionstr.h"
#include "miscstruct.h"
+#include "privates.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
@@ -40,7 +41,7 @@
typedef struct _Glyph {
CARD32 refcnt;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
unsigned char sha1[20];
CARD32 size; /* info + bitmap */
xGlyphInfo info;
@@ -74,18 +75,14 @@ typedef struct _GlyphSet {
int fdepth;
GlyphHashRec hash;
int maxPrivate;
- pointer *devPrivates;
+ PrivateRec *devPrivates;
} GlyphSetRec, *GlyphSetPtr;
-#define GlyphSetGetPrivate(pGlyphSet,n) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- (pointer) 0 : \
- (pGlyphSet)->devPrivates[n])
+#define GlyphSetGetPrivate(pGlyphSet,k) \
+ dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
-#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
- ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
+#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
+ dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
typedef struct _GlyphList {
INT16 xOff;
@@ -97,32 +94,6 @@ typedef struct _GlyphList {
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
-int
-AllocateGlyphSetPrivateIndex (void);
-
-void
-ResetGlyphSetPrivateIndex (void);
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr);
-
-void
-ResetGlyphPrivates (void);
-
-int
-AllocateGlyphPrivateIndex (void);
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount);
-
-Bool
-GlyphInit (ScreenPtr pScreen);
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen);
-
void
GlyphUninit (ScreenPtr pScreen);
diff --git a/render/mirect.c b/render/mirect.c
index 464df51c1..38f4faf67 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -158,7 +158,7 @@ miCompositeRects (CARD8 op,
tmpval[0] = xTrue;
pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
- CPRepeat, tmpval, 0, &error);
+ CPRepeat, tmpval, serverClient, &error);
if (!pSrc)
goto bail4;
diff --git a/render/picture.c b/render/picture.c
index a7e40f994..35e2a28b3 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -40,66 +40,17 @@
#include "gcstruct.h"
#include "servermd.h"
#include "picturestr.h"
+#include "xace.h"
+#include "registry.h"
-_X_EXPORT int PictureScreenPrivateIndex = -1;
-int PictureWindowPrivateIndex;
+_X_EXPORT DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKey;
+DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKey;
static int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
RESTYPE GlyphSetType;
int PictureCmapPolicy = PictureCmapPolicyDefault;
-/* Picture Private machinery */
-
-static int picturePrivateCount;
-
-void
-ResetPicturePrivateIndex (void)
-{
- picturePrivateCount = 0;
-}
-
-int
-AllocatePicturePrivateIndex (void)
-{
- return picturePrivateCount++;
-}
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- unsigned int oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= ps->PicturePrivateLen)
- {
- unsigned int *nsizes;
-
- nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes,
- (index2 + 1) * sizeof(unsigned int));
- if (!nsizes)
- return FALSE;
- while (ps->PicturePrivateLen <= index2)
- {
- nsizes[ps->PicturePrivateLen++] = 0;
- ps->totalPictureSize += sizeof(DevUnion);
- }
- ps->PicturePrivateSizes = nsizes;
- }
- oldamount = ps->PicturePrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->PicturePrivateSizes[index2] = amount;
- ps->totalPictureSize += (amount - oldamount);
- }
-
- return TRUE;
-}
-
-
Bool
PictureDestroyWindow (WindowPtr pWindow)
{
@@ -137,8 +88,6 @@ PictureCloseScreen (int index, ScreenPtr pScreen)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
- if (ps->PicturePrivateSizes)
- xfree (ps->PicturePrivateSizes);
xfree (ps->formats);
xfree (ps);
return ret;
@@ -497,8 +446,6 @@ PictureFinishInit (void)
for (s = 0; s < screenInfo.numScreens; s++)
{
- if (!GlyphFinishInit (screenInfo.screens[s]))
- return FALSE;
if (!PictureInitIndexedFormats (screenInfo.screens[s]))
return FALSE;
(void) AnimCurInit (screenInfo.screens[s]);
@@ -637,20 +584,11 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
GlyphSetType = CreateNewResourceType (FreeGlyphSet);
if (!GlyphSetType)
return FALSE;
- PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (PictureScreenPrivateIndex < 0)
- return FALSE;
- PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
-#ifdef XResExtension
RegisterResourceName (PictureType, "PICTURE");
RegisterResourceName (PictFormatType, "PICTFORMAT");
RegisterResourceName (GlyphSetType, "GLYPHSET");
-#endif
}
- if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
- return FALSE;
-
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -697,18 +635,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
}
SetPictureScreen(pScreen, ps);
- if (!GlyphInit (pScreen))
- {
- SetPictureScreen(pScreen, 0);
- xfree (formats);
- xfree (ps);
- return FALSE;
- }
- ps->totalPictureSize = sizeof (PictureRec);
- ps->PicturePrivateSizes = 0;
- ps->PicturePrivateLen = 0;
-
ps->formats = formats;
ps->fallback = formats;
ps->nformats = nformats;
@@ -774,37 +701,6 @@ SetPictureToDefaults (PicturePtr pPicture)
}
PicturePtr
-AllocatePicture (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- PicturePtr pPicture;
- char *ptr;
- DevUnion *ppriv;
- unsigned int *sizes;
- unsigned int size;
- int i;
-
- pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
- if (!pPicture)
- return 0;
- ppriv = (DevUnion *)(pPicture + 1);
- pPicture->devPrivates = ppriv;
- sizes = ps->PicturePrivateSizes;
- ptr = (char *)(ppriv + ps->PicturePrivateLen);
- for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- return pPicture;
-}
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -816,7 +712,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = AllocatePicture (pDrawable->pScreen);
+ pPicture = (PicturePtr)xalloc(sizeof(PictureRec));
if (!pPicture)
{
*error = BadAlloc;
@@ -827,6 +723,14 @@ CreatePicture (Picture pid,
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
+ pPicture->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ *error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,
+ RT_PIXMAP, pDrawable, DixCreateAccess|DixSetAttrAccess);
+ if (*error != Success)
+ goto out;
+
if (pDrawable->type == DRAWABLE_PIXMAP)
{
++((PixmapPtr)pDrawable)->refcnt;
@@ -846,6 +750,7 @@ CreatePicture (Picture pid,
*error = Success;
if (*error == Success)
*error = (*ps->CreatePicture) (pPicture);
+out:
if (*error != Success)
{
FreePicture (pPicture, (XID) 0);
@@ -1163,14 +1068,13 @@ ChangePicture (PicturePtr pPicture,
pAlpha = 0;
else
{
- pAlpha = (PicturePtr) SecurityLookupIDByType(client,
- pid,
- PictureType,
- DixWriteAccess|DixReadAccess);
- if (!pAlpha)
+ error = dixLookupResource((pointer *)&pAlpha, pid,
+ PictureType, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
if (pAlpha->pDrawable == NULL ||
@@ -1225,14 +1129,13 @@ ChangePicture (PicturePtr pPicture,
else
{
clipType = CT_PIXMAP;
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- pid,
- RT_PIXMAP,
- DixReadAccess);
- if (!pPixmap)
+ error = dixLookupResource((pointer *)&pPixmap, pid,
+ RT_PIXMAP, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
}
@@ -1607,7 +1510,8 @@ FreePicture (pointer value,
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PicturePtr *pPrev;
- for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+ for (pPrev = (PicturePtr *)dixLookupPrivateAddr
+ (&pWindow->devPrivates, PictureWindowPrivateKey);
*pPrev;
pPrev = &(*pPrev)->pNext)
{
@@ -1623,6 +1527,7 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
+ dixFreePrivates(pPicture->devPrivates);
xfree (pPicture);
}
return Success;
diff --git a/render/picturestr.h b/render/picturestr.h
index b2e180f11..4dfa94402 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -27,6 +27,7 @@
#include "scrnintstr.h"
#include "glyphstr.h"
#include "resource.h"
+#include "privates.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
@@ -173,7 +174,7 @@ typedef struct _Picture {
RegionPtr pCompositeClip;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
PictTransform *transform;
@@ -328,10 +329,6 @@ typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen,
GlyphPtr glyph);
typedef struct _PictureScreen {
- int totalPictureSize;
- unsigned int *PicturePrivateSizes;
- int PicturePrivateLen;
-
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
@@ -389,30 +386,25 @@ typedef struct _PictureScreen {
AddTrapsProcPtr AddTraps;
- int totalGlyphPrivateSize;
- unsigned int *glyphPrivateSizes;
- int glyphPrivateLen;
- int glyphPrivateOffset;
-
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
} PictureScreenRec, *PictureScreenPtr;
-extern int PictureScreenPrivateIndex;
-extern int PictureWindowPrivateIndex;
+extern DevPrivateKey PictureScreenPrivateKey;
+extern DevPrivateKey PictureWindowPrivateKey;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
-#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
-#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
-#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
-#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
-#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
+#define GetPictureScreenIfSet(s) GetPictureScreen(s)
+#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
+#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
+#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
-#define GetGlyphPrivatesForScreen(glyph, s) \
- ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset)
+#define GetGlyphPrivatesForScreen(glyph, s) \
+ ((PrivateRec **)dixLookupPrivateAddr(&(glyph)->devPrivates, s))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
@@ -430,15 +422,6 @@ extern RESTYPE GlyphSetType;
} \
} \
-void
-ResetPicturePrivateIndex (void);
-
-int
-AllocatePicturePrivateIndex (void);
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
-
Bool
PictureDestroyWindow (WindowPtr pWindow);
@@ -501,9 +484,6 @@ PictureFinishInit (void);
void
SetPictureToDefaults (PicturePtr pPicture);
-PicturePtr
-AllocatePicture (ScreenPtr pScreen);
-
#if 0
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
@@ -650,7 +630,7 @@ Bool
AnimCurInit (ScreenPtr pScreen);
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid);
void
AddTraps (PicturePtr pPicture,
diff --git a/render/render.c b/render/render.c
index 3a9d24a02..040a9507f 100644
--- a/render/render.c
+++ b/render/render.c
@@ -40,12 +40,14 @@
#include "colormapst.h"
#include "extnsionst.h"
#include "servermd.h"
+#include "registry.h"
#include <X11/extensions/render.h>
#include <X11/extensions/renderproto.h>
#include "picturestr.h"
#include "glyphstr.h"
#include <X11/Xfuncproto.h>
#include "cursorstr.h"
+#include "xace.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -216,14 +218,14 @@ RenderResetProc (ExtensionEntry *extEntry);
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 +249,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;
@@ -263,13 +263,100 @@ RenderExtensionInit (void)
RenderReqCode = (CARD8) extEntry->base;
#endif
RenderErrBase = extEntry->errorBase;
+
+ RegisterRequestName(extEntry->base, X_RenderQueryVersion,
+ RENDER_NAME ":QueryVersion");
+ RegisterRequestName(extEntry->base, X_RenderQueryPictFormats,
+ RENDER_NAME ":QueryPictFormats");
+ RegisterRequestName(extEntry->base, X_RenderQueryPictIndexValues,
+ RENDER_NAME ":QueryPictIndexValues");
+ RegisterRequestName(extEntry->base, X_RenderQueryDithers,
+ RENDER_NAME ":QueryDithers");
+ RegisterRequestName(extEntry->base, X_RenderCreatePicture,
+ RENDER_NAME ":CreatePicture");
+ RegisterRequestName(extEntry->base, X_RenderChangePicture,
+ RENDER_NAME ":ChangePicture");
+ RegisterRequestName(extEntry->base, X_RenderSetPictureClipRectangles,
+ RENDER_NAME ":SetPictureClipRectangles");
+ RegisterRequestName(extEntry->base, X_RenderFreePicture,
+ RENDER_NAME ":FreePicture");
+ RegisterRequestName(extEntry->base, X_RenderComposite,
+ RENDER_NAME ":Composite");
+ RegisterRequestName(extEntry->base, X_RenderScale,
+ RENDER_NAME ":Scale");
+ RegisterRequestName(extEntry->base, X_RenderTrapezoids,
+ RENDER_NAME ":Trapezoids");
+ RegisterRequestName(extEntry->base, X_RenderTriangles,
+ RENDER_NAME ":Triangles");
+ RegisterRequestName(extEntry->base, X_RenderTriStrip,
+ RENDER_NAME ":TriStrip");
+ RegisterRequestName(extEntry->base, X_RenderTriFan,
+ RENDER_NAME ":TriFan");
+ RegisterRequestName(extEntry->base, X_RenderColorTrapezoids,
+ RENDER_NAME ":ColorTrapezoids");
+ RegisterRequestName(extEntry->base, X_RenderColorTriangles,
+ RENDER_NAME ":ColorTriangles");
+ RegisterRequestName(extEntry->base, X_RenderCreateGlyphSet,
+ RENDER_NAME ":CreateGlyphSet");
+ RegisterRequestName(extEntry->base, X_RenderReferenceGlyphSet,
+ RENDER_NAME ":ReferenceGlyphSet");
+ RegisterRequestName(extEntry->base, X_RenderFreeGlyphSet,
+ RENDER_NAME ":FreeGlyphSet");
+ RegisterRequestName(extEntry->base, X_RenderAddGlyphs,
+ RENDER_NAME ":AddGlyphs");
+ RegisterRequestName(extEntry->base, X_RenderAddGlyphsFromPicture,
+ RENDER_NAME ":AddGlyphsFromPicture");
+ RegisterRequestName(extEntry->base, X_RenderFreeGlyphs,
+ RENDER_NAME ":FreeGlyphs");
+ RegisterRequestName(extEntry->base, X_RenderCompositeGlyphs8,
+ RENDER_NAME ":CompositeGlyphs8");
+ RegisterRequestName(extEntry->base, X_RenderCompositeGlyphs16,
+ RENDER_NAME ":CompositeGlyphs16");
+ RegisterRequestName(extEntry->base, X_RenderCompositeGlyphs32,
+ RENDER_NAME ":CompositeGlyphs32");
+ RegisterRequestName(extEntry->base, X_RenderFillRectangles,
+ RENDER_NAME ":FillRectangles");
+ /* 0.5 */
+ RegisterRequestName(extEntry->base, X_RenderCreateCursor,
+ RENDER_NAME ":CreateCursor");
+ /* 0.6 */
+ RegisterRequestName(extEntry->base, X_RenderSetPictureTransform,
+ RENDER_NAME ":SetPictureTransform");
+ RegisterRequestName(extEntry->base, X_RenderQueryFilters,
+ RENDER_NAME ":QueryFilters");
+ RegisterRequestName(extEntry->base, X_RenderSetPictureFilter,
+ RENDER_NAME ":SetPictureFilter");
+ /* 0.8 */
+ RegisterRequestName(extEntry->base, X_RenderCreateAnimCursor,
+ RENDER_NAME ":CreateAnimCursor");
+ /* 0.9 */
+ RegisterRequestName(extEntry->base, X_RenderAddTraps,
+ RENDER_NAME ":AddTraps");
+ /* 0.10 */
+ RegisterRequestName(extEntry->base, X_RenderCreateSolidFill,
+ RENDER_NAME ":CreateSolidFill");
+ RegisterRequestName(extEntry->base, X_RenderCreateLinearGradient,
+ RENDER_NAME ":CreateLinearGradient");
+ RegisterRequestName(extEntry->base, X_RenderCreateRadialGradient,
+ RENDER_NAME ":CreateRadialGradient");
+ RegisterRequestName(extEntry->base, X_RenderCreateConicalGradient,
+ RENDER_NAME ":CreateConicalGradient");
+
+ RegisterErrorName(RenderErrBase + BadPictFormat,
+ RENDER_NAME ":BadPictFormat");
+ RegisterErrorName(RenderErrBase + BadPicture,
+ RENDER_NAME ":BadPicture");
+ RegisterErrorName(RenderErrBase + BadPictOp,
+ RENDER_NAME ":BadPictOp");
+ RegisterErrorName(RenderErrBase + BadGlyphSet,
+ RENDER_NAME ":BadGlyphSet");
+ RegisterErrorName(RenderErrBase + BadGlyph,
+ RENDER_NAME ":BadGlyph");
}
static void
RenderResetProc (ExtensionEntry *extEntry)
{
- ResetPicturePrivateIndex();
- ResetGlyphSetPrivateIndex();
}
static int
@@ -627,7 +714,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 +755,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 +775,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 +1074,7 @@ ProcRenderCreateGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
PictFormatPtr format;
- int f;
+ int rc, f;
REQUEST(xRenderCreateGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
@@ -1026,6 +1113,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 +1127,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 +1154,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 +1190,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;
@@ -1286,19 +1375,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 +1462,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
stuff->glyphset,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = stuff->glyphset;
@@ -1437,7 +1524,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
gs,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = gs;
@@ -1579,7 +1666,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 +1834,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 +1858,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 +1883,7 @@ ProcRenderQueryFilters (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -1897,7 +1988,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 +2032,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 +2079,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 +2113,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 +2148,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 +2182,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;