summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-28 17:20:58 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-28 17:20:58 +1000
commitd7aef3f663f4b5d861799f8615dcd301d5ce2906 (patch)
tree3a5ed1b3dc7e83536979578e3da99f2860f44b11 /Xext
parenta25f248fc3bd0375d91ca8a44320200d445ecfbb (diff)
parente08c6a0752772745f35f7afcf6c2b1c927b91cc0 (diff)
Merge branch 'master' into xi2
Conflicts: Xext/geext.c Xi/chdevcur.c Xi/extgrbdev.c Xi/xiproperty.c configure.ac dix/ptrveloc.c hw/xfree86/common/xf86Config.c mi/mipointer.h test/input.c xkb/xkb.c
Diffstat (limited to 'Xext')
-rw-r--r--Xext/panoramiX.c7
-rw-r--r--Xext/panoramiX.h2
-rw-r--r--Xext/panoramiXprocs.c671
-rw-r--r--Xext/saver.c54
-rw-r--r--Xext/security.c11
-rw-r--r--Xext/shape.c75
-rw-r--r--Xext/shm.c34
-rw-r--r--Xext/sync.c82
-rw-r--r--Xext/xf86bigfont.c14
-rw-r--r--Xext/xselinux.c9
-rw-r--r--Xext/xvdisp.c234
-rw-r--r--Xext/xvdix.h18
-rw-r--r--Xext/xvmain.c9
-rw-r--r--Xext/xvmc.c57
14 files changed, 657 insertions, 620 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 767f6035e..4ab6f6bdd 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -354,9 +354,12 @@ PanoramiXRes *
PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
{
PanoramiXSearchData data;
+ pointer val;
- if(!screen)
- return LookupIDByType(id, type);
+ if(!screen) {
+ dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess);
+ return val;
+ }
data.screen = screen;
data.id = id;
diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index d413ff9cf..cca4c5249 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -97,6 +97,4 @@ typedef struct {
#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
-#define SKIP_FAKE_WINDOW(a) if(!LookupIDByType(a, XRT_WINDOW)) return
-
#endif /* _PANORAMIX_H_ */
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 72a207ab8..8b51009b3 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -67,7 +67,7 @@ int PanoramiXCreateWindow(ClientPtr client)
PanoramiXRes *cmap = NULL;
REQUEST(xCreateWindowReq);
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
- int result = 0, len, j;
+ int result, len, j;
int orig_x, orig_y;
XID orig_visual, tmp;
Bool parentIsRoot;
@@ -78,9 +78,10 @@ int PanoramiXCreateWindow(ClientPtr client)
if (Ones(stuff->mask) != len)
return BadLength;
- if (!(parent = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->parent, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&parent, stuff->parent,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
if(stuff->class == CopyFromParent)
stuff->class = parent->u.win.class;
@@ -92,27 +93,30 @@ int PanoramiXCreateWindow(ClientPtr client)
pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) {
- if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&backPix, tmp,
+ XRT_PIXMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & CWBorderPixmap) {
pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) {
- if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&bordPix, tmp,
+ XRT_PIXMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & CWColormap) {
cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if ((tmp != CopyFromParent) && (tmp != None)) {
- if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_COLORMAP, DixReadAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, tmp,
+ XRT_COLORMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
}
}
@@ -170,7 +174,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
PanoramiXRes *cmap = NULL;
REQUEST(xChangeWindowAttributesReq);
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
- int result = 0, len, j;
+ int result, len, j;
XID tmp;
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
@@ -179,9 +183,10 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
if (Ones(stuff->valueMask) != len)
return BadLength;
- if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
if((win->u.win.class == InputOnly) &&
(stuff->valueMask & (~INPUTONLY_LEGAL_MASK)))
@@ -191,27 +196,30 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) {
- if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&backPix, tmp,
+ XRT_PIXMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->valueMask & CWBorderPixmap) {
pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) {
- if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&bordPix, tmp,
+ XRT_PIXMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->valueMask & CWColormap) {
cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if ((tmp != CopyFromParent) && (tmp != None)) {
- if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_COLORMAP, DixReadAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, tmp,
+ XRT_COLORMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
}
}
@@ -233,14 +241,15 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
int PanoramiXDestroyWindow(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixDestroyAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW,
+ client, DixDestroyAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = win->info[j].id;
@@ -258,14 +267,15 @@ int PanoramiXDestroyWindow(ClientPtr client)
int PanoramiXDestroySubwindows(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixDestroyAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW,
+ client, DixDestroyAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = win->info[j].id;
@@ -283,14 +293,15 @@ int PanoramiXDestroySubwindows(ClientPtr client)
int PanoramiXChangeSaveSet(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xChangeSaveSetReq);
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->window = win->info[j].id;
@@ -305,20 +316,22 @@ int PanoramiXChangeSaveSet(ClientPtr client)
int PanoramiXReparentWindow(ClientPtr client)
{
PanoramiXRes *win, *parent;
- int result = 0, j;
+ int result, j;
int x, y;
Bool parentIsRoot;
REQUEST(xReparentWindowReq);
REQUEST_SIZE_MATCH(xReparentWindowReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
- if(!(parent = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->parent, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&parent, stuff->parent,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
x = stuff->x;
y = stuff->y;
@@ -342,14 +355,15 @@ int PanoramiXReparentWindow(ClientPtr client)
int PanoramiXMapWindow(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_FORWARD(j) {
stuff->id = win->info[j].id;
@@ -364,14 +378,15 @@ int PanoramiXMapWindow(ClientPtr client)
int PanoramiXMapSubwindows(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_FORWARD(j) {
stuff->id = win->info[j].id;
@@ -386,14 +401,15 @@ int PanoramiXMapSubwindows(ClientPtr client)
int PanoramiXUnmapWindow(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_FORWARD(j) {
stuff->id = win->info[j].id;
@@ -408,14 +424,15 @@ int PanoramiXUnmapWindow(ClientPtr client)
int PanoramiXUnmapSubwindows(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->id,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_FORWARD(j) {
stuff->id = win->info[j].id;
@@ -432,7 +449,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
PanoramiXRes *win;
PanoramiXRes *sib = NULL;
WindowPtr pWin;
- int result = 0, j, len, sib_offset = 0, x = 0, y = 0;
+ int result, j, len, sib_offset = 0, x = 0, y = 0;
int x_offset = -1;
int y_offset = -1;
REQUEST(xConfigureWindowReq);
@@ -444,21 +461,24 @@ int PanoramiXConfigureWindow(ClientPtr client)
return BadLength;
/* because we need the parent */
- if (!(pWin = (WindowPtr)SecurityLookupIDByType(
- client, stuff->window, RT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&pWin, stuff->window,
+ RT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
- if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
if ((Mask)stuff->mask & CWSibling) {
XID tmp;
sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1));
if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) {
- if(!(sib = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
}
}
@@ -496,14 +516,15 @@ int PanoramiXConfigureWindow(ClientPtr client)
int PanoramiXCirculateWindow(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j;
+ int result, j;
REQUEST(xCirculateWindowReq);
REQUEST_SIZE_MATCH(xCirculateWindowReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS_FORWARD(j) {
stuff->window = win->info[j].id;
@@ -634,15 +655,16 @@ int PanoramiXTranslateCoords(ClientPtr client)
int PanoramiXCreatePixmap(ClientPtr client)
{
PanoramiXRes *refDraw, *newPix;
- int result = 0, j;
+ int result, j;
REQUEST(xCreatePixmapReq);
REQUEST_SIZE_MATCH(xCreatePixmapReq);
client->errorValue = stuff->pid;
- if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixReadAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable,
+ XRC_DRAWABLE, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(!(newPix = xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
@@ -672,16 +694,17 @@ int PanoramiXCreatePixmap(ClientPtr client)
int PanoramiXFreePixmap(ClientPtr client)
{
PanoramiXRes *pix;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id;
- if(!(pix = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_PIXMAP, DixDestroyAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP,
+ client, DixDestroyAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = pix->info[j].id;
@@ -705,7 +728,7 @@ int PanoramiXCreateGC(ClientPtr client)
PanoramiXRes *clip = NULL;
REQUEST(xCreateGCReq);
int tile_offset = 0, stip_offset = 0, clip_offset = 0;
- int result = 0, len, j;
+ int result, len, j;
XID tmp;
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
@@ -715,32 +738,36 @@ int PanoramiXCreateGC(ClientPtr client)
if (Ones(stuff->mask) != len)
return BadLength;
- if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixReadAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable,
+ XRC_DRAWABLE, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if ((Mask)stuff->mask & GCTile) {
tile_offset = Ones((Mask)stuff->mask & (GCTile - 1));
if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) {
- if(!(tile = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & GCStipple) {
stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1));
if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) {
- if(!(stip = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & GCClipMask) {
clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1));
if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) {
- if(!(clip = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
@@ -781,7 +808,7 @@ int PanoramiXChangeGC(ClientPtr client)
PanoramiXRes *clip = NULL;
REQUEST(xChangeGCReq);
int tile_offset = 0, stip_offset = 0, clip_offset = 0;
- int result = 0, len, j;
+ int result, len, j;
XID tmp;
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
@@ -790,32 +817,36 @@ int PanoramiXChangeGC(ClientPtr client)
if (Ones(stuff->mask) != len)
return BadLength;
- if (!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
if ((Mask)stuff->mask & GCTile) {
tile_offset = Ones((Mask)stuff->mask & (GCTile - 1));
if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) {
- if(!(tile = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & GCStipple) {
stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1));
if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) {
- if(!(stip = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
if ((Mask)stuff->mask & GCClipMask) {
clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1));
if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) {
- if(!(clip = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
}
}
@@ -839,18 +870,20 @@ int PanoramiXChangeGC(ClientPtr client)
int PanoramiXCopyGC(ClientPtr client)
{
PanoramiXRes *srcGC, *dstGC;
- int result = 0, j;
+ int result, j;
REQUEST(xCopyGCReq);
REQUEST_SIZE_MATCH(xCopyGCReq);
- if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->srcGC, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
- if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->dstGC, XRT_GC, DixWriteAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
FOR_NSCREENS(j) {
stuff->srcGC = srcGC->info[j].id;
@@ -866,14 +899,15 @@ int PanoramiXCopyGC(ClientPtr client)
int PanoramiXSetDashes(ClientPtr client)
{
PanoramiXRes *gc;
- int result = 0, j;
+ int result, j;
REQUEST(xSetDashesReq);
REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixWriteAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->gc = gc->info[j].id;
@@ -888,14 +922,15 @@ int PanoramiXSetDashes(ClientPtr client)
int PanoramiXSetClipRectangles(ClientPtr client)
{
PanoramiXRes *gc;
- int result = 0, j;
+ int result, j;
REQUEST(xSetClipRectanglesReq);
REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixWriteAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->gc = gc->info[j].id;
@@ -910,14 +945,15 @@ int PanoramiXSetClipRectangles(ClientPtr client)
int PanoramiXFreeGC(ClientPtr client)
{
PanoramiXRes *gc;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_GC, DixDestroyAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC,
+ client, DixDestroyAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = gc->info[j].id;
@@ -935,15 +971,16 @@ int PanoramiXFreeGC(ClientPtr client)
int PanoramiXClearToBackground(ClientPtr client)
{
PanoramiXRes *win;
- int result = 0, j, x, y;
+ int result, j, x, y;
Bool isRoot;
REQUEST(xClearAreaReq);
REQUEST_SIZE_MATCH(xClearAreaReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
x = stuff->x;
y = stuff->y;
@@ -974,7 +1011,7 @@ int PanoramiXClearToBackground(ClientPtr client)
int PanoramiXCopyArea(ClientPtr client)
{
- int j, result = 0, srcx, srcy, dstx, dsty;
+ int j, result, srcx, srcy, dstx, dsty;
PanoramiXRes *gc, *src, *dst;
Bool srcIsRoot = FALSE;
Bool dstIsRoot = FALSE;
@@ -983,24 +1020,27 @@ int PanoramiXCopyArea(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyAreaReq);
- if(!(src = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable,
+ XRC_DRAWABLE, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
srcShared = IS_SHARED_PIXMAP(src);
- if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
dstShared = IS_SHARED_PIXMAP(dst);
if(dstShared && srcShared)
return (* SavedProcVector[X_CopyArea])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
if((dst->type == XRT_WINDOW) && dst->u.win.root)
dstIsRoot = TRUE;
@@ -1139,24 +1179,27 @@ int PanoramiXCopyPlane(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyPlaneReq);
- if(!(src = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess)))
- return BadDrawable;
+ rc = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable,
+ XRC_DRAWABLE, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadDrawable : rc;
srcShared = IS_SHARED_PIXMAP(src);
- if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ rc = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadDrawable : rc;
dstShared = IS_SHARED_PIXMAP(dst);
if(dstShared && srcShared)
return (* SavedProcVector[X_CopyPlane])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadGC : rc;
if((dst->type == XRT_WINDOW) && dst->u.win.root)
dstIsRoot = TRUE;
@@ -1235,23 +1278,25 @@ int PanoramiXCopyPlane(ClientPtr client)
int PanoramiXPolyPoint(ClientPtr client)
{
PanoramiXRes *gc, *draw;
- int result = 0, npoint, j;
+ int result, npoint, j;
xPoint *origPts;
Bool isRoot;
REQUEST(xPolyPointReq);
REQUEST_AT_LEAST_SIZE(xPolyPointReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyPoint])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
@@ -1293,23 +1338,25 @@ int PanoramiXPolyPoint(ClientPtr client)
int PanoramiXPolyLine(ClientPtr client)
{
PanoramiXRes *gc, *draw;
- int result = 0, npoint, j;
+ int result, npoint, j;
xPoint *origPts;
Bool isRoot;
REQUEST(xPolyLineReq);
REQUEST_AT_LEAST_SIZE(xPolyLineReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyLine])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
@@ -1350,7 +1397,7 @@ int PanoramiXPolyLine(ClientPtr client)
int PanoramiXPolySegment(ClientPtr client)
{
- int result = 0, nsegs, i, j;
+ int result, nsegs, i, j;
PanoramiXRes *gc, *draw;
xSegment *origSegs;
Bool isRoot;
@@ -1358,16 +1405,18 @@ int PanoramiXPolySegment(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolySegment])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1411,7 +1460,7 @@ int PanoramiXPolySegment(ClientPtr client)
int PanoramiXPolyRectangle(ClientPtr client)
{
- int result = 0, nrects, i, j;
+ int result, nrects, i, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
xRectangle *origRecs;
@@ -1419,17 +1468,18 @@ int PanoramiXPolyRectangle(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
-
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyRectangle])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1472,7 +1522,7 @@ int PanoramiXPolyRectangle(ClientPtr client)
int PanoramiXPolyArc(ClientPtr client)
{
- int result = 0, narcs, i, j;
+ int result, narcs, i, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
xArc *origArcs;
@@ -1480,16 +1530,18 @@ int PanoramiXPolyArc(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPolyArcReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyArc])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1530,7 +1582,7 @@ int PanoramiXPolyArc(ClientPtr client)
int PanoramiXFillPoly(ClientPtr client)
{
- int result = 0, count, j;
+ int result, count, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
DDXPointPtr locPts;
@@ -1538,16 +1590,18 @@ int PanoramiXFillPoly(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xFillPolyReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_FillPoly])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1589,7 +1643,7 @@ int PanoramiXFillPoly(ClientPtr client)
int PanoramiXPolyFillRectangle(ClientPtr client)
{
- int result = 0, things, i, j;
+ int result, things, i, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
xRectangle *origRects;
@@ -1597,16 +1651,18 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyFillRectangle])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1650,22 +1706,24 @@ int PanoramiXPolyFillArc(ClientPtr client)
{
PanoramiXRes *gc, *draw;
Bool isRoot;
- int result = 0, narcs, i, j;
+ int result, narcs, i, j;
xArc *origArcs;
REQUEST(xPolyFillArcReq);
REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyFillArc])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1709,21 +1767,23 @@ int PanoramiXPutImage(ClientPtr client)
{
PanoramiXRes *gc, *draw;
Bool isRoot;
- int j, result = 0, orig_x, orig_y;
+ int j, result, orig_x, orig_y;
REQUEST(xPutImageReq);
REQUEST_AT_LEAST_SIZE(xPutImageReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PutImage])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1765,9 +1825,10 @@ int PanoramiXGetImage(ClientPtr client)
return(BadValue);
}
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadDrawable : rc;
if(draw->type == XRT_PIXMAP)
return (*SavedProcVector[X_GetImage])(client);
@@ -1906,22 +1967,24 @@ PanoramiXPolyText8(ClientPtr client)
{
PanoramiXRes *gc, *draw;
Bool isRoot;
- int result = 0, j;
+ int result, j;
int orig_x, orig_y;
REQUEST(xPolyTextReq);
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyText8])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1945,22 +2008,24 @@ PanoramiXPolyText16(ClientPtr client)
{
PanoramiXRes *gc, *draw;
Bool isRoot;
- int result = 0, j;
+ int result, j;
int orig_x, orig_y;
REQUEST(xPolyTextReq);
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_PolyText16])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1982,7 +2047,7 @@ PanoramiXPolyText16(ClientPtr client)
int PanoramiXImageText8(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
int orig_x, orig_y;
@@ -1990,16 +2055,18 @@ int PanoramiXImageText8(ClientPtr client)
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_ImageText8])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -2021,7 +2088,7 @@ int PanoramiXImageText8(ClientPtr client)
int PanoramiXImageText16(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *gc, *draw;
Bool isRoot;
int orig_x, orig_y;
@@ -2029,16 +2096,18 @@ int PanoramiXImageText16(ClientPtr client)
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(IS_SHARED_PIXMAP(draw))
return (*SavedProcVector[X_ImageText16])(client);
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -2062,14 +2131,15 @@ int PanoramiXImageText16(ClientPtr client)
int PanoramiXCreateColormap(ClientPtr client)
{
PanoramiXRes *win, *newCmap;
- int result = 0, j, orig_visual;
+ int result, j, orig_visual;
REQUEST(xCreateColormapReq);
REQUEST_SIZE_MATCH(xCreateColormapReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->window, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->window,
+ XRT_WINDOW, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
@@ -2100,16 +2170,17 @@ int PanoramiXCreateColormap(ClientPtr client)
int PanoramiXFreeColormap(ClientPtr client)
{
PanoramiXRes *cmap;
- int result = 0, j;
+ int result, j;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_COLORMAP, DixDestroyAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
+ client, DixDestroyAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = cmap->info[j].id;
@@ -2128,17 +2199,18 @@ int
PanoramiXCopyColormapAndFree(ClientPtr client)
{
PanoramiXRes *cmap, *newCmap;
- int result = 0, j;
+ int result, j;
REQUEST(xCopyColormapAndFreeReq);
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
client->errorValue = stuff->srcCmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->srcCmap, XRT_COLORMAP,
- DixReadAccess | DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->srcCmap,
+ XRT_COLORMAP, client,
+ DixReadAccess | DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
@@ -2167,16 +2239,17 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
int PanoramiXInstallColormap(ClientPtr client)
{
REQUEST(xResourceReq);
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_COLORMAP, DixReadAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->id = cmap->info[j].id;
@@ -2190,16 +2263,17 @@ int PanoramiXInstallColormap(ClientPtr client)
int PanoramiXUninstallColormap(ClientPtr client)
{
REQUEST(xResourceReq);
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->id, XRT_COLORMAP, DixReadAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->id = cmap->info[j].id;
@@ -2212,7 +2286,7 @@ int PanoramiXUninstallColormap(ClientPtr client)
int PanoramiXAllocColor(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xAllocColorReq);
@@ -2220,9 +2294,10 @@ int PanoramiXAllocColor(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
@@ -2235,7 +2310,7 @@ int PanoramiXAllocColor(ClientPtr client)
int PanoramiXAllocNamedColor(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xAllocNamedColorReq);
@@ -2243,9 +2318,10 @@ int PanoramiXAllocNamedColor(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
@@ -2258,7 +2334,7 @@ int PanoramiXAllocNamedColor(ClientPtr client)
int PanoramiXAllocColorCells(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xAllocColorCellsReq);
@@ -2266,9 +2342,10 @@ int PanoramiXAllocColorCells(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
@@ -2281,7 +2358,7 @@ int PanoramiXAllocColorCells(ClientPtr client)
int PanoramiXAllocColorPlanes(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xAllocColorPlanesReq);
@@ -2289,9 +2366,10 @@ int PanoramiXAllocColorPlanes(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
@@ -2305,7 +2383,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client)
int PanoramiXFreeColors(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xFreeColorsReq);
@@ -2313,9 +2391,10 @@ int PanoramiXFreeColors(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j) {
stuff->cmap = cmap->info[j].id;
@@ -2327,7 +2406,7 @@ int PanoramiXFreeColors(ClientPtr client)
int PanoramiXStoreColors(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xStoreColorsReq);
@@ -2335,9 +2414,10 @@ int PanoramiXStoreColors(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
@@ -2350,7 +2430,7 @@ int PanoramiXStoreColors(ClientPtr client)
int PanoramiXStoreNamedColor(ClientPtr client)
{
- int result = 0, j;
+ int result, j;
PanoramiXRes *cmap;
REQUEST(xStoreNamedColorReq);
@@ -2358,9 +2438,10 @@ int PanoramiXStoreNamedColor(ClientPtr client)
client->errorValue = stuff->cmap;
- if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->cmap, XRT_COLORMAP, DixWriteAccess)))
- return BadColor;
+ result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
+ XRT_COLORMAP, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadColor : result;
FOR_NSCREENS_BACKWARD(j){
stuff->cmap = cmap->info[j].id;
diff --git a/Xext/saver.c b/Xext/saver.c
index 357c2155f..b59f769d5 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -533,11 +533,14 @@ UninstallSaverColormap (ScreenPtr pScreen)
{
SetupScreen(pScreen);
ColormapPtr pCmap;
+ int rc;
if (pPriv && pPriv->installedMap != None)
{
- pCmap = (ColormapPtr) LookupIDByType (pPriv->installedMap, RT_COLORMAP);
- if (pCmap)
+ rc = dixLookupResourceByType((pointer *)&pCmap, pPriv->installedMap,
+ RT_COLORMAP, serverClient,
+ DixUninstallAccess);
+ if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap);
pPriv->installedMap = None;
CheckScreenPrivate (pScreen);
@@ -651,8 +654,9 @@ CreateSaverWindow (ScreenPtr pScreen)
if (i < numInstalled)
return TRUE;
- pCmap = (ColormapPtr) LookupIDByType (wantMap, RT_COLORMAP);
- if (!pCmap)
+ result = dixLookupResourceByType((pointer *)&pCmap, wantMap, RT_COLORMAP,
+ serverClient, DixInstallAccess);
+ if (result != Success)
return TRUE;
pPriv->installedMap = wantMap;
@@ -1252,15 +1256,16 @@ ProcScreenSaverSetAttributes (ClientPtr client)
PanoramiXRes *backPix = NULL;
PanoramiXRes *bordPix = NULL;
PanoramiXRes *cmap = NULL;
- int i, status = 0, len;
+ int i, status, len;
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
XID orig_visual, tmp;
REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ status = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (status != Success)
+ return (status == BadValue) ? BadDrawable : status;
len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
if (Ones(stuff->mask) != len)
@@ -1270,9 +1275,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) {
- if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ status = dixLookupResourceByType((pointer *)&backPix, tmp,
+ XRT_PIXMAP, client,
+ DixReadAccess);
+ if (status != Success)
+ return (status == BadValue) ? BadPixmap : status;
}
}
@@ -1280,9 +1287,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) {
- if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ status = dixLookupResourceByType((pointer *)&bordPix, tmp,
+ XRT_PIXMAP, client,
+ DixReadAccess);
+ if (status != Success)
+ return (status == BadValue) ? BadPixmap : status;
}
}
@@ -1290,9 +1299,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if ((tmp != CopyFromParent) && (tmp != None)) {
- if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
- client, tmp, XRT_COLORMAP, DixReadAccess)))
- return BadColor;
+ status = dixLookupResourceByType((pointer *)&cmap, tmp,
+ XRT_COLORMAP, client,
+ DixReadAccess);
+ if (status != Success)
+ return (status == BadValue) ? BadColor : status;
}
}
@@ -1327,11 +1338,12 @@ ProcScreenSaverUnsetAttributes (ClientPtr client)
if(!noPanoramiXExtension) {
REQUEST(xScreenSaverUnsetAttributesReq);
PanoramiXRes *draw;
- int i;
+ int rc, i;
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadDrawable : rc;
for(i = PanoramiXNumScreens - 1; i > 0; i--) {
stuff->drawable = draw->info[i].id;
diff --git a/Xext/security.c b/Xext/security.c
index 7962fdb37..bae95a3b5 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -623,13 +623,16 @@ ProcSecurityRevokeAuthorization(
{
REQUEST(xSecurityRevokeAuthorizationReq);
SecurityAuthorizationPtr pAuth;
+ int rc;
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
- pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client,
- stuff->authId, SecurityAuthorizationResType, DixDestroyAccess);
- if (!pAuth)
- return SecurityErrorBase + XSecurityBadAuthorization;
+ rc = dixLookupResourceByType((pointer *)&pAuth, stuff->authId,
+ SecurityAuthorizationResType, client,
+ DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ?
+ SecurityErrorBase + XSecurityBadAuthorization : rc;
FreeResource(stuff->authId, RT_NONE);
return Success;
diff --git a/Xext/shape.c b/Xext/shape.c
index 15d2c5c5a..5977296e5 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -353,13 +353,14 @@ ProcPanoramiXShapeRectangles(
{
REQUEST(xShapeRectanglesReq);
PanoramiXRes *win;
- int j, result = 0;
+ int j, result;
REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->dest, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) {
stuff->dest = win->info[j].id;
@@ -451,18 +452,20 @@ ProcPanoramiXShapeMask(
{
REQUEST(xShapeMaskReq);
PanoramiXRes *win, *pmap;
- int j, result = 0;
+ int j, result;
REQUEST_SIZE_MATCH (xShapeMaskReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->dest, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
if(stuff->src != None) {
- if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->src, XRT_PIXMAP, DixReadAccess)))
- return BadPixmap;
+ result = dixLookupResourceByType((pointer *)&pmap, stuff->src,
+ XRT_PIXMAP, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadPixmap : result;
} else
pmap = NULL;
@@ -579,17 +582,19 @@ ProcPanoramiXShapeCombine(
{
REQUEST(xShapeCombineReq);
PanoramiXRes *win, *win2;
- int j, result = 0;
+ int j, result;
REQUEST_AT_LEAST_SIZE (xShapeCombineReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->dest, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
- if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->src, XRT_WINDOW, DixReadAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win2, stuff->src, XRT_WINDOW,
+ client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) {
stuff->dest = win->info[j].id;
@@ -651,13 +656,14 @@ ProcPanoramiXShapeOffset(
{
REQUEST(xShapeOffsetReq);
PanoramiXRes *win;
- int j, result = 0;
+ int j, result;
REQUEST_AT_LEAST_SIZE (xShapeOffsetReq);
- if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->dest, XRT_WINDOW, DixWriteAccess)))
- return BadWindow;
+ result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
+ client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) {
stuff->dest = win->info[j].id;
@@ -740,11 +746,13 @@ ShapeFreeClient (pointer data, XID id)
ShapeEventPtr pShapeEvent;
WindowPtr pWin;
ShapeEventPtr *pHead, pCur, pPrev;
+ int rc;
pShapeEvent = (ShapeEventPtr) data;
pWin = pShapeEvent->window;
- pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, ShapeEventType);
- if (pHead) {
+ rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ ShapeEventType, serverClient, DixReadAccess);
+ if (rc == Success) {
pPrev = 0;
for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next)
pPrev = pCur;
@@ -789,8 +797,11 @@ ProcShapeSelectInput (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success)
return rc;
- pHead = (ShapeEventPtr *)SecurityLookupIDByType(client,
- pWin->drawable.id, ShapeEventType, DixWriteAccess);
+ rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ ShapeEventType, client, DixWriteAccess);
+ if (rc != Success && rc != BadValue)
+ return rc;
+
switch (stuff->enable) {
case xTrue:
if (pHead) {
@@ -879,9 +890,11 @@ SendShapeNotify (WindowPtr pWin, int which)
BoxRec extents;
RegionPtr region;
BYTE shaped;
+ int rc;
- pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, ShapeEventType);
- if (!pHead)
+ rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ ShapeEventType, serverClient, DixReadAccess);
+ if (rc != Success)
return;
switch (which) {
case ShapeBounding:
@@ -958,8 +971,10 @@ ProcShapeInputSelected (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
- pHead = (ShapeEventPtr *) SecurityLookupIDByType(client,
- pWin->drawable.id, ShapeEventType, DixReadAccess);
+ rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ ShapeEventType, client, DixReadAccess);
+ if (rc != Success && rc != BadValue)
+ return rc;
enabled = xFalse;
if (pHead) {
for (pShapeEvent = *pHead;
diff --git a/Xext/shm.c b/Xext/shm.c
index 1f963c16c..cdda09f7f 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -144,12 +144,11 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
#define VERIFY_SHMSEG(shmseg,shmdesc,client) \
{ \
- shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \
- if (!shmdesc) \
- { \
- client->errorValue = shmseg; \
- return BadShmSegCode; \
- } \
+ int rc; \
+ rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \
+ client, DixReadAccess); \
+ if (rc != Success) \
+ return (rc == BadValue) ? BadShmSegCode : rc; \
}
#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
@@ -513,20 +512,22 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
static int
ProcPanoramiXShmPutImage(ClientPtr client)
{
- int j, result = 0, orig_x, orig_y;
+ int j, result, orig_x, orig_y;
PanoramiXRes *draw, *gc;
Bool sendEvent, isRoot;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
+ XRT_GC, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -570,9 +571,10 @@ ProcPanoramiXShmGetImage(ClientPtr client)
return(BadValue);
}
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadDrawable : rc;
if (draw->type == XRT_PIXMAP)
return ProcShmGetImage(client);
diff --git a/Xext/sync.c b/Xext/sync.c
index adb732447..d7ab63cd5 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -1339,16 +1339,14 @@ ProcSyncSetCounter(ClientPtr client)
REQUEST(xSyncSetCounterReq);
SyncCounter *pCounter;
CARD64 newvalue;
+ int rc;
REQUEST_SIZE_MATCH(xSyncSetCounterReq);
- pCounter = SecurityLookupIDByType(client, stuff->cid, RTCounter,
- DixWriteAccess);
- if (pCounter == NULL)
- {
- client->errorValue = stuff->cid;
- return SyncErrorBase + XSyncBadCounter;
- }
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
if (IsSystemCounter(pCounter))
{
@@ -1371,16 +1369,14 @@ ProcSyncChangeCounter(ClientPtr client)
SyncCounter *pCounter;
CARD64 newvalue;
Bool overflow;
+ int rc;
REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
- pCounter = SecurityLookupIDByType(client, stuff->cid, RTCounter,
- DixWriteAccess);
- if (pCounter == NULL)
- {
- client->errorValue = stuff->cid;
- return SyncErrorBase + XSyncBadCounter;
- }
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
if (IsSystemCounter(pCounter))
{
@@ -1408,16 +1404,15 @@ ProcSyncDestroyCounter(ClientPtr client)
{
REQUEST(xSyncDestroyCounterReq);
SyncCounter *pCounter;
+ int rc;
REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
- pCounter = SecurityLookupIDByType(client, stuff->counter, RTCounter,
- DixDestroyAccess);
- if (pCounter == NULL)
- {
- client->errorValue = stuff->counter;
- return SyncErrorBase + XSyncBadCounter;
- }
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+
if (IsSystemCounter(pCounter))
{
client->errorValue = stuff->counter;
@@ -1552,16 +1547,14 @@ ProcSyncQueryCounter(ClientPtr client)
REQUEST(xSyncQueryCounterReq);
xSyncQueryCounterReply rep;
SyncCounter *pCounter;
+ int rc;
REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
- pCounter = SecurityLookupIDByType(client, stuff->counter, RTCounter,
- DixReadAccess);
- if (pCounter == NULL)
- {
- client->errorValue = stuff->counter;
- return SyncErrorBase + XSyncBadCounter;
- }
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
+ RTCounter, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
rep.type = X_Reply;
rep.length = 0;
@@ -1682,12 +1675,10 @@ ProcSyncChangeAlarm(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
- if (!(pAlarm = SecurityLookupIDByType(client, stuff->alarm, RTAlarm,
- DixWriteAccess)))
- {
- client->errorValue = stuff->alarm;
- return SyncErrorBase + XSyncBadAlarm;
- }
+ status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixWriteAccess);
+ if (status != Success)
+ return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
vmask = stuff->valueMask;
len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2);
@@ -1719,16 +1710,14 @@ ProcSyncQueryAlarm(ClientPtr client)
SyncAlarm *pAlarm;
xSyncQueryAlarmReply rep;
SyncTrigger *pTrigger;
+ int rc;
REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
- pAlarm = SecurityLookupIDByType(client, stuff->alarm, RTAlarm,
- DixReadAccess);
- if (!pAlarm)
- {
- client->errorValue = stuff->alarm;
- return SyncErrorBase + XSyncBadAlarm;
- }
+ rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
rep.type = X_Reply;
rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2;
@@ -1776,16 +1765,15 @@ ProcSyncQueryAlarm(ClientPtr client)
static int
ProcSyncDestroyAlarm(ClientPtr client)
{
+ SyncAlarm *pAlarm;
+ int rc;
REQUEST(xSyncDestroyAlarmReq);
REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
- if (!(SecurityLookupIDByType(client, stuff->alarm, RTAlarm,
- DixDestroyAccess)))
- {
- client->errorValue = stuff->alarm;
- return SyncErrorBase + XSyncBadAlarm;
- }
+ rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixDestroyAccess);
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
FreeResource(stuff->alarm, RT_NONE);
return client->noClientException;
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 60189666e..7d4c69766 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -427,15 +427,15 @@ ProcXF86BigfontQueryFont(
}
#endif
client->errorValue = stuff->id; /* EITHER font or gc */
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- DixGetAttrAccess);
+ dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT,
+ client, DixGetAttrAccess);
if (!pFont) {
- GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
- DixGetAttrAccess);
- if (!pGC) {
- client->errorValue = stuff->id;
+ GC *pGC;
+ dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC,
+ client, DixGetAttrAccess);
+ if (!pGC)
return BadFont; /* procotol spec says only error is BadFont */
- }
+
pFont = pGC->font;
}
diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 2c7262140..3a6f0960d 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1346,15 +1346,6 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
goto out;
privPtr = &serverClient->devPrivates;
}
- else if (offset == USE_SEL) {
- /* Selection use context currently requires no selections owned */
- Selection *pSel;
- for (pSel = CurrentSelections; pSel; pSel = pSel->next)
- if (pSel->client == client) {
- rc = BadMatch;
- goto out;
- }
- }
ptr = dixLookupPrivate(privPtr, subjectKey);
pSid = (security_id_t *)(ptr + offset);
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index 770c53a27..fcb61e476 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -479,11 +479,7 @@ ProcXvQueryEncodings(ClientPtr client)
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -540,12 +536,7 @@ ProcXvPutVideo(ClientPtr client)
REQUEST_SIZE_MATCH(xvPutVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -583,12 +574,7 @@ ProcXvPutStill(ClientPtr client)
REQUEST_SIZE_MATCH(xvPutStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -626,12 +612,7 @@ ProcXvGetVideo(ClientPtr client)
REQUEST_SIZE_MATCH(xvGetVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -669,12 +650,7 @@ ProcXvGetStill(ClientPtr client)
REQUEST_SIZE_MATCH(xvGetStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -723,11 +699,7 @@ ProcXvSelectPortNotify(ClientPtr client)
REQUEST(xvSelectPortNotifyReq);
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -747,11 +719,7 @@ ProcXvGrabPort(ClientPtr client)
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -784,11 +752,7 @@ ProcXvUngrabPort(ClientPtr client)
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -808,11 +772,7 @@ ProcXvStopVideo(ClientPtr client)
REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -835,11 +795,7 @@ ProcXvSetPortAttribute(ClientPtr client)
REQUEST(xvSetPortAttributeReq);
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -873,11 +829,7 @@ ProcXvGetPortAttribute(ClientPtr client)
REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -918,11 +870,7 @@ ProcXvQueryBestSize(ClientPtr client)
REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -959,11 +907,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
REQUEST(xvQueryPortAttributesReq);
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -1019,12 +963,7 @@ ProcXvPutImage(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -1105,12 +1044,7 @@ ProcXvShmPutImage(ClientPtr client)
REQUEST_SIZE_MATCH(xvShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
@@ -1141,11 +1075,10 @@ ProcXvShmPutImage(ClientPtr client)
if(!pImage)
return BadMatch;
- if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType)))
- {
- client->errorValue = stuff->shmseg;
- return BadShmSegCode;
- }
+ status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg,
+ ShmSegType, serverClient, DixReadAccess);
+ if (status != Success)
+ return (status == BadValue) ? BadShmSegCode : status;
width = stuff->width;
height = stuff->height;
@@ -1206,11 +1139,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
@@ -1269,11 +1198,7 @@ ProcXvListImageFormats(ClientPtr client)
REQUEST_SIZE_MATCH(xvListImageFormatsReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
- {
- client->errorValue = stuff->port;
- return (_XvBadPort);
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -1679,18 +1604,20 @@ SProcXvDispatch(ClientPtr client)
static int
XineramaXvStopVideo(ClientPtr client)
{
- int result = Success, i;
+ int result, i;
PanoramiXRes *draw, *port;
REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
@@ -1708,13 +1635,14 @@ XineramaXvSetPortAttribute(ClientPtr client)
{
REQUEST(xvSetPortAttributeReq);
PanoramiXRes *port;
- int result = Success, i;
+ int result, i;
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) {
@@ -1733,21 +1661,24 @@ XineramaXvShmPutImage(ClientPtr client)
PanoramiXRes *draw, *gc, *port;
Bool send_event = stuff->send_event;
Bool isRoot;
- int result = Success, i, x, y;
+ int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
+ XRT_GC, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1782,21 +1713,24 @@ XineramaXvPutImage(ClientPtr client)
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
- int result = Success, i, x, y;
+ int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
+ XRT_GC, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1827,21 +1761,24 @@ XineramaXvPutVideo(ClientPtr client)
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
- int result = Success, i, x, y;
+ int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
+ XRT_GC, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@@ -1872,21 +1809,24 @@ XineramaXvPutStill(ClientPtr client)
REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port;
Bool isRoot;
- int result = Success, i, x, y;
+ int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
- if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
- if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->gc, XRT_GC, DixReadAccess)))
- return BadGC;
+ result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
+ XRT_GC, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadGC : result;
- if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
- client, stuff->port, XvXRTPort, DixReadAccess)))
- return _XvBadPort;
+ result = dixLookupResourceByType((pointer *)&port, stuff->port,
+ XvXRTPort, client, DixReadAccess);
+ if (result != Success)
+ return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 265c03ddf..44f8f6b18 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -201,17 +201,13 @@ typedef struct _XvPortRec {
DevUnion devPriv;
} XvPortRec, *XvPortPtr;
-#define LOOKUP_PORT(_id, client)\
- ((XvPortPtr)LookupIDByType(_id, XvRTPort))
-
-#define LOOKUP_ENCODING(_id, client)\
- ((XvEncodingPtr)LookupIDByType(_id, XvRTEncoding))
-
-#define LOOKUP_VIDEONOTIFY_LIST(_id, client)\
- ((XvVideoNotifyPtr)LookupIDByType(_id, XvRTVideoNotifyList))
-
-#define LOOKUP_PORTNOTIFY_LIST(_id, client)\
- ((XvPortNotifyPtr)LookupIDByType(_id, XvRTPortNotifyList))
+#define VALIDATE_XV_PORT(portID, pPort, mode)\
+ {\
+ int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
+ XvRTPort, client, mode);\
+ if (rc != Success)\
+ return (rc == BadValue) ? _XvBadPort : rc;\
+ }
typedef struct {
int version, revision;
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 477194684..7c8a3c3d4 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -523,7 +523,8 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
xvEvent event;
XvVideoNotifyPtr pn;
- pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList);
+ dixLookupResourceByType((pointer *)&pn, pDraw->id, XvRTVideoNotifyList,
+ serverClient, DixReadAccess);
while (pn)
{
@@ -905,10 +906,14 @@ XvdiSelectVideoNotify(
BOOL onoff
){
XvVideoNotifyPtr pn,tpn,fpn;
+ int rc;
/* FIND VideoNotify LIST */
- pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList);
+ rc = dixLookupResourceByType((pointer *)&pn, pDraw->id, XvRTVideoNotifyList,
+ client, DixWriteAccess);
+ if (rc != Success && rc != BadValue)
+ return rc;
/* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 9166cf892..879a222bd 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -136,10 +136,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
- client->errorValue = stuff->port;
- return _XvBadPort;
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(XvMCScreenKey) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
@@ -192,10 +189,7 @@ ProcXvMCCreateContext(ClientPtr client)
REQUEST(xvmcCreateContextReq);
REQUEST_SIZE_MATCH(xvmcCreateContextReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
- client->errorValue = stuff->port;
- return _XvBadPort;
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
pScreen = pPort->pAdaptor->pScreen;
@@ -273,11 +267,15 @@ ProcXvMCCreateContext(ClientPtr client)
static int
ProcXvMCDestroyContext(ClientPtr client)
{
+ pointer val;
+ int rc;
REQUEST(xvmcDestroyContextReq);
REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
- if(!LookupIDByType(stuff->context_id, XvMCRTContext))
- return (XvMCBadContext + XvMCErrorBase);
+ rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? XvMCBadContext + XvMCErrorBase : rc;
FreeResource(stuff->context_id, RT_NONE);
@@ -297,8 +295,10 @@ ProcXvMCCreateSurface(ClientPtr client)
REQUEST(xvmcCreateSurfaceReq);
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
- if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext)))
- return (XvMCBadContext + XvMCErrorBase);
+ result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
+ XvMCRTContext, client, DixUseAccess);
+ if (result != Success)
+ return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
@@ -337,11 +337,15 @@ ProcXvMCCreateSurface(ClientPtr client)
static int
ProcXvMCDestroySurface(ClientPtr client)
{
+ pointer val;
+ int rc;
REQUEST(xvmcDestroySurfaceReq);
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
- if(!LookupIDByType(stuff->surface_id, XvMCRTSurface))
- return (XvMCBadSurface + XvMCErrorBase);
+ rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? XvMCBadSurface + XvMCErrorBase : rc;
FreeResource(stuff->surface_id, RT_NONE);
@@ -363,8 +367,10 @@ ProcXvMCCreateSubpicture(ClientPtr client)
REQUEST(xvmcCreateSubpictureReq);
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
- if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext)))
- return (XvMCBadContext + XvMCErrorBase);
+ result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
+ XvMCRTContext, client, DixUseAccess);
+ if (result != Success)
+ return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
@@ -448,11 +454,15 @@ ProcXvMCCreateSubpicture(ClientPtr client)
static int
ProcXvMCDestroySubpicture(ClientPtr client)
{
+ pointer val;
+ int rc;
REQUEST(xvmcDestroySubpictureReq);
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
- if(!LookupIDByType(stuff->subpicture_id, XvMCRTSubpicture))
- return (XvMCBadSubpicture + XvMCErrorBase);
+ rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? XvMCBadSubpicture + XvMCErrorBase : rc;
FreeResource(stuff->subpicture_id, RT_NONE);
@@ -475,10 +485,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
REQUEST(xvmcListSubpictureTypesReq);
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
- if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
- client->errorValue = stuff->port;
- return _XvBadPort;
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
pScreen = pPort->pAdaptor->pScreen;
@@ -571,11 +578,7 @@ ProcXvMCGetDRInfo(ClientPtr client)
REQUEST(xvmcGetDRInfoReq);
REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
-
- if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
- client->errorValue = stuff->port;
- return _XvBadPort;
- }
+ VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen);