summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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/xvdisp.c234
-rw-r--r--Xext/xvdix.h18
-rw-r--r--Xext/xvmain.c9
-rw-r--r--Xext/xvmc.c57
-rw-r--r--Xi/chdevcur.c10
-rw-r--r--Xi/extgrbdev.c14
-rw-r--r--damageext/damageextint.h9
-rw-r--r--dbe/dbe.c33
-rw-r--r--dix/colormap.c26
-rw-r--r--dix/cursor.c5
-rw-r--r--dix/deprecated.c8
-rw-r--r--dix/dispatch.c9
-rw-r--r--dix/dixfonts.c61
-rw-r--r--dix/dixutils.c11
-rw-r--r--dix/events.c13
-rw-r--r--dix/resource.c22
-rw-r--r--dix/window.c58
-rw-r--r--fb/fbcmap.c6
-rw-r--r--hw/kdrive/src/kcmap.c3
-rw-r--r--hw/vfb/InitOutput.c6
-rw-r--r--hw/xfree86/common/xf86cmap.c4
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dga2.c18
-rw-r--r--hw/xfree86/dri/dri.c5
-rw-r--r--hw/xfree86/vgahw/vgaCmap.c4
-rw-r--r--hw/xnest/Color.c22
-rw-r--r--hw/xnest/Window.c9
-rw-r--r--mi/micmap.c6
-rw-r--r--mi/miexpose.c2
-rw-r--r--randr/randr.c6
-rw-r--r--randr/randrstr.h32
-rw-r--r--randr/rrcrtc.c61
-rw-r--r--randr/rrdispatch.c7
-rw-r--r--randr/rrmode.c40
-rw-r--r--randr/rroutput.c37
-rw-r--r--randr/rrproperty.c33
-rw-r--r--record/record.c9
-rw-r--r--render/picture.c5
-rw-r--r--render/picturestr.h9
-rw-r--r--render/render.c170
-rw-r--r--xfixes/cursor.c7
-rw-r--r--xfixes/select.c6
50 files changed, 1017 insertions, 1037 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/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);
diff --git a/Xi/chdevcur.c b/Xi/chdevcur.c
index b0d3ce341..d7a9e4952 100644
--- a/Xi/chdevcur.c
+++ b/Xi/chdevcur.c
@@ -94,12 +94,10 @@ int ProcXChangeDeviceCursor(ClientPtr client)
}
else
{
- pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, DixReadAccess);
- if (!pCursor)
- {
- return BadCursor;
- }
+ rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor,
+ RT_CURSOR, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadCursor : rc;
}
ChangeWindowDeviceCursor(pWin, pDev, pCursor);
diff --git a/Xi/extgrbdev.c b/Xi/extgrbdev.c
index af8706320..0f64610b5 100644
--- a/Xi/extgrbdev.c
+++ b/Xi/extgrbdev.c
@@ -88,7 +88,7 @@ ProcXExtendedGrabDevice(ClientPtr client)
{
xExtendedGrabDeviceReply rep;
DeviceIntPtr dev;
- int rc = Success,
+ int rc,
errval = 0,
i;
WindowPtr grab_window,
@@ -145,14 +145,12 @@ ProcXExtendedGrabDevice(ClientPtr client)
if (stuff->cursor)
{
- cursor = (CursorPtr)SecurityLookupIDByType(client,
- stuff->cursor,
- RT_CURSOR,
- DixReadAccess);
- if (!cursor)
- {
+ rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor,
+ RT_CURSOR, client, DixReadAccess);
+ if (rc != Success)
+ {
errval = stuff->cursor;
- rc = BadCursor;
+ rc = (rc == BadValue) ? BadCursor : rc;
goto cleanup;
}
}
diff --git a/damageext/damageextint.h b/damageext/damageextint.h
index 543f1a70b..45c5ff96c 100644
--- a/damageext/damageextint.h
+++ b/damageext/damageextint.h
@@ -58,11 +58,10 @@ typedef struct _DamageExt {
} DamageExtRec, *DamageExtPtr;
#define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
- pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \
- if (!pDamageExt) { \
- client->errorValue = rid; \
- return DamageErrorBase + BadDamage; \
- } \
+ int rc = dixLookupResourceByType((pointer *)&(pDamageExt), rid, \
+ DamageExtType, client, mode); \
+ if (rc != Success) \
+ return (rc == BadValue) ? DamageErrorBase + BadDamage : rc; \
}
void
diff --git a/dbe/dbe.c b/dbe/dbe.c
index 3fd99dfc9..b8f61e742 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -411,20 +411,23 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
{
REQUEST(xDbeDeallocateBackBufferNameReq);
DbeWindowPrivPtr pDbeWindowPriv;
- int i;
+ int rc, i;
+ pointer val;
REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
/* Buffer name must be valid */
- if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client,
- stuff->buffer, dbeWindowPrivResType, DixDestroyAccess)) ||
- !(SecurityLookupIDByType(client, stuff->buffer, dbeDrawableResType,
- DixDestroyAccess)))
- {
- client->errorValue = stuff->buffer;
- return(dbeErrorBase + DbeBadBuffer);
- }
+ rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
+ dbeWindowPrivResType, client,
+ DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? dbeErrorBase + DbeBadBuffer : rc;
+
+ rc = dixLookupResourceByType(&val, stuff->buffer, dbeDrawableResType,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? dbeErrorBase + DbeBadBuffer : rc;
/* Make sure that the id is valid for the window.
* This is paranoid code since we already looked up the ID by type
@@ -833,19 +836,21 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
REQUEST(xDbeGetBackBufferAttributesReq);
xDbeGetBackBufferAttributesReply rep;
DbeWindowPrivPtr pDbeWindowPriv;
- int n;
+ int rc, n;
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
- if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client,
- stuff->buffer, dbeWindowPrivResType, DixGetAttrAccess)))
+ rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
+ dbeWindowPrivResType, client,
+ DixGetAttrAccess);
+ if (rc == Success)
{
- rep.attributes = None;
+ rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
}
else
{
- rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
+ rep.attributes = None;
}
rep.type = X_Reply;
diff --git a/dix/colormap.c b/dix/colormap.c
index 6a5eb74a1..a5a006e60 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -893,9 +893,9 @@ AllocColor (ColormapPtr pmap,
if (pmap->mid != pmap->pScreen->defColormap &&
pmap->pVisual->vid == pmap->pScreen->rootVisual)
{
- ColormapPtr prootmap = (ColormapPtr)
- SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap,
- RT_COLORMAP, DixReadAccess);
+ ColormapPtr prootmap;
+ dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, clients[client], DixReadAccess);
if (pmap->class == prootmap->class)
FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
@@ -910,9 +910,9 @@ AllocColor (ColormapPtr pmap,
if (pmap->mid != pmap->pScreen->defColormap &&
pmap->pVisual->vid == pmap->pScreen->rootVisual)
{
- ColormapPtr prootmap = (ColormapPtr)
- SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap,
- RT_COLORMAP, DixReadAccess);
+ ColormapPtr prootmap;
+ dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, clients[client], DixReadAccess);
if (pmap->class == prootmap->class)
{
@@ -1550,12 +1550,14 @@ FreePixels(ColormapPtr pmap, int client)
int
FreeClientPixels (pointer value, XID fakeid)
{
- ColormapPtr pmap;
- colorResource *pcr = (colorResource *)value;
-
- pmap = (ColormapPtr) LookupIDByType(pcr->mid, RT_COLORMAP);
- if (pmap)
- FreePixels(pmap, pcr->client);
+ pointer pmap;
+ colorResource *pcr = value;
+ int rc;
+
+ rc = dixLookupResourceByType(&pmap, pcr->mid, RT_COLORMAP, serverClient,
+ DixRemoveAccess);
+ if (rc == Success)
+ FreePixels((ColormapPtr)pmap, pcr->client);
xfree(pcr);
return Success;
}
diff --git a/dix/cursor.c b/dix/cursor.c
index 7ab15df0c..086d008e0 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -545,8 +545,9 @@ CreateRootCursor(char *unused1, unsigned int unused2)
if (err != Success)
return NullCursor;
- cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT);
- if (!cursorfont)
+ err = dixLookupResourceByType((pointer *)&cursorfont, fontID, RT_FONT,
+ serverClient, DixReadAccess);
+ if (err != Success)
return NullCursor;
if (AllocGlyphCursor(fontID, 0, fontID, 1, 0, 0, 0, ~0, ~0, ~0,
&curs, serverClient, (XID)0) != Success)
diff --git a/dix/deprecated.c b/dix/deprecated.c
index 5487b64bc..8123886ca 100644
--- a/dix/deprecated.c
+++ b/dix/deprecated.c
@@ -148,14 +148,18 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
pointer
LookupIDByType(XID id, RESTYPE rtype)
{
- return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess);
+ pointer val;
+ dixLookupResourceByType(&val, id, rtype, NullClient, DixUnknownAccess);
+ return val;
}
/* replaced by dixLookupResourceByClass */
pointer
LookupIDByClass(XID id, RESTYPE classes)
{
- return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess);
+ pointer val;
+ dixLookupResourceByClass(&val, id, classes, NullClient, DixUnknownAccess);
+ return val;
}
/* replaced by dixLookupResourceBy{Type,Class} */
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 16a51bdc5..ce3294d32 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1252,12 +1252,13 @@ int
ProcCloseFont(ClientPtr client)
{
FontPtr pFont;
+ int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- DixDestroyAccess);
- if ( pFont != (FontPtr)NULL) /* id was valid */
+ rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT,
+ client, DixDestroyAccess);
+ if (rc == Success)
{
FreeResource(stuff->id, RT_NONE);
return(client->noClientException);
@@ -1265,7 +1266,7 @@ ProcCloseFont(ClientPtr client)
else
{
client->errorValue = stuff->id;
- return (BadFont);
+ return (rc == BadValue) ? BadFont : rc;
}
}
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 79489e81f..8b6e7a329 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -137,8 +137,9 @@ SetDefaultFont(char *defaultfontname)
(unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success)
return FALSE;
- pf = (FontPtr) LookupIDByType(fid, RT_FONT);
- if (pf == (FontPtr) NULL)
+ err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
+ DixReadAccess);
+ if (err != Success)
return FALSE;
defaultFont = pf;
return TRUE;
@@ -1201,17 +1202,18 @@ doPolyText(ClientPtr client, PTclosurePtr c)
}
/* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, DixWriteAccess))
+ if (c->slept && c->pDraw)
{
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client and avoid further
- rendering while we clean up after ourself. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- c->pDraw = (DrawablePtr)0;
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
}
client_state = c->slept ? SLEEPING : NEVER_SLEPT;
@@ -1233,12 +1235,11 @@ doPolyText(ClientPtr client, PTclosurePtr c)
| ((Font)*(c->pElt+3)) << 8
| ((Font)*(c->pElt+2)) << 16
| ((Font)*(c->pElt+1)) << 24;
- pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
- DixReadAccess);
- if (!pFont)
+ err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
+ client, DixReadAccess);
+ if (err != Success)
{
- client->errorValue = fid;
- err = BadFont;
+ err = (err == BadValue) ? BadFont : err;
/* restore pFont and fid for step 4 (described below) */
pFont = oldpFont;
fid = oldfid;
@@ -1486,17 +1487,18 @@ doImageText(ClientPtr client, ITclosurePtr c)
}
/* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, DixWriteAccess))
+ if (c->slept && c->pDraw)
{
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
}
lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
@@ -2013,8 +2015,9 @@ FreeFonts(void)
FontPtr
find_old_font(XID id)
{
- return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
- DixUnknownAccess);
+ pointer pFont;
+ dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
+ return (FontPtr)pFont;
}
Font
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 1bdeee064..5cede5f43 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -240,14 +240,9 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
int
dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
{
- GCPtr pTmp = (GCPtr)SecurityLookupIDByType(client, id, RT_GC, access);
- if (pTmp) {
- *pGC = pTmp;
- return Success;
- }
- client->errorValue = id;
- *pGC = NULL;
- return BadGC;
+ int rc;
+ rc = dixLookupResourceByType((pointer *)pGC, id, RT_GC, client, access);
+ return (rc == BadValue) ? BadGC : rc;
}
int
diff --git a/dix/events.c b/dix/events.c
index 8af71b645..be88891a4 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -506,16 +506,17 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
PanoramiXNumScreens*sizeof(WindowPtr));
} else {
PanoramiXRes *win;
- int i;
-
- win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW);
+ int rc, i;
- if(!win)
+ rc = dixLookupResourceByType((pointer *)&win, pWin->drawable.id,
+ XRT_WINDOW, serverClient, DixReadAccess);
+ if (rc != Success)
return FALSE;
for(i = 0; i < PanoramiXNumScreens; i++) {
- pSprite->windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW);
- if(!pSprite->windows[i]) /* window is being unmapped */
+ rc = dixLookupWindow(pSprite->windows + i, win->info[i].id,
+ serverClient, DixReadAccess);
+ if (rc != Success) /* window is being unmapped */
return FALSE;
}
}
diff --git a/dix/resource.c b/dix/resource.c
index dc6945dd1..73bc3a998 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -392,13 +392,16 @@ unsigned int
GetXIDList(ClientPtr pClient, unsigned count, XID *pids)
{
unsigned int found = 0;
- XID id = pClient->clientAsMask;
+ XID rc, id = pClient->clientAsMask;
XID maxid;
+ pointer val;
maxid = id | RESOURCE_ID_MASK;
while ( (found < count) && (id <= maxid) )
{
- if (!LookupIDByClass(id, RC_ANY))
+ rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient,
+ DixGetAttrAccess);
+ if (rc == BadValue)
{
pids[found++] = id;
}
@@ -826,6 +829,8 @@ FreeAllResources(void)
Bool
LegalNewID(XID id, ClientPtr client)
{
+ pointer val;
+ int rc;
#ifdef PANORAMIX
XID minid, maxid;
@@ -838,9 +843,16 @@ LegalNewID(XID id, ClientPtr client)
return TRUE;
}
#endif /* PANORAMIX */
- return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) &&
- ((clientTable[client->index].expectID <= id) ||
- !LookupIDByClass(id, RC_ANY)));
+ if (client->clientAsMask == (id & ~RESOURCE_ID_MASK))
+ {
+ if (clientTable[client->index].expectID <= id)
+ return TRUE;
+
+ rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient,
+ DixGetAttrAccess);
+ return (rc == BadValue);
+ }
+ return FALSE;
}
int
diff --git a/dix/window.c b/dix/window.c
index f112f81d4..324ddb71e 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2795,6 +2795,7 @@ UnrealizeTree(
WindowPtr pChild;
UnrealizeWindowProcPtr Unrealize;
MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
+ int rc;
Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
@@ -2808,9 +2809,10 @@ UnrealizeTree(
#ifdef PANORAMIX
if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) {
PanoramiXRes *win;
- win = (PanoramiXRes*)LookupIDByType(pChild->drawable.id,
- XRT_WINDOW);
- if(win)
+ rc = dixLookupResourceByType((pointer *)&win,
+ pChild->drawable.id, XRT_WINDOW,
+ serverClient, DixWriteAccess);
+ if (rc == Success)
win->u.win.visibility = VisibilityNotViewable;
}
#endif
@@ -3072,7 +3074,7 @@ SendVisibilityNotify(WindowPtr pWin)
if(!noPanoramiXExtension) {
PanoramiXRes *win;
WindowPtr pWin2;
- int i, Scrnum;
+ int rc, i, Scrnum;
Scrnum = pWin->drawable.pScreen->myNum;
@@ -3086,9 +3088,10 @@ SendVisibilityNotify(WindowPtr pWin)
for(i = 0; i < PanoramiXNumScreens; i++) {
if(i == Scrnum) continue;
- pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+ rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
+ DixWriteAccess);
- if (pWin2) {
+ if (rc == Success) {
if(pWin2->visibility == VisibilityPartiallyObscured)
return;
@@ -3098,17 +3101,19 @@ SendVisibilityNotify(WindowPtr pWin)
break;
case VisibilityPartiallyObscured:
if(Scrnum) {
- pWin2 = (WindowPtr)LookupIDByType(win->info[0].id, RT_WINDOW);
- if (pWin2) pWin = pWin2;
+ rc = dixLookupWindow(&pWin2, win->info[0].id, serverClient,
+ DixWriteAccess);
+ if (rc == Success) pWin = pWin2;
}
break;
case VisibilityFullyObscured:
for(i = 0; i < PanoramiXNumScreens; i++) {
if(i == Scrnum) continue;
- pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+ rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
+ DixWriteAccess);
- if (pWin2) {
+ if (rc == Success) {
if(pWin2->visibility != VisibilityFullyObscured)
return;
@@ -3739,7 +3744,7 @@ DrawLogo(WindowPtr pWin)
int x, y;
unsigned int width, height, size;
GC *pGC;
- int thin, gap, d31;
+ int rc, thin, gap, d31;
DDXPointRec poly[4];
ChangeGCVal fore[2], back[2];
xrgb rgb[2];
@@ -3760,20 +3765,23 @@ DrawLogo(WindowPtr pWin)
fore[0].val = pScreen->whitePixel;
else
fore[0].val = pScreen->blackPixel;
- if ((pWin->backgroundState == BackgroundPixel) &&
- (cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) {
- Pixel querypixels[2];
-
- querypixels[0] = fore[0].val;
- querypixels[1] = pWin->background.pixel;
- QueryColors(cmap, 2, querypixels, rgb);
- if ((rgb[0].red == rgb[1].red) &&
- (rgb[0].green == rgb[1].green) &&
- (rgb[0].blue == rgb[1].blue)) {
- if (fore[0].val == pScreen->blackPixel)
- fore[0].val = pScreen->whitePixel;
- else
- fore[0].val = pScreen->blackPixel;
+ if (pWin->backgroundState == BackgroundPixel) {
+ rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixReadAccess);
+ if (rc == Success) {
+ Pixel querypixels[2];
+
+ querypixels[0] = fore[0].val;
+ querypixels[1] = pWin->background.pixel;
+ QueryColors(cmap, 2, querypixels, rgb);
+ if ((rgb[0].red == rgb[1].red) &&
+ (rgb[0].green == rgb[1].green) &&
+ (rgb[0].blue == rgb[1].blue)) {
+ if (fore[0].val == pScreen->blackPixel)
+ fore[0].val = pScreen->whitePixel;
+ else
+ fore[0].val = pScreen->blackPixel;
+ }
}
}
fore[1].val = FillSolid;
diff --git a/fb/fbcmap.c b/fb/fbcmap.c
index c29a5131c..207c6aefc 100644
--- a/fb/fbcmap.c
+++ b/fb/fbcmap.c
@@ -85,8 +85,10 @@ fbUninstallColormap(ColormapPtr pmap)
{
if (pmap->mid != pmap->pScreen->defColormap)
{
- curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&curpmap,
+ pmap->pScreen->defColormap,
+ RT_COLORMAP,
+ serverClient, DixInstallAccess);
(*pmap->pScreen->InstallColormap)(curpmap);
}
}
diff --git a/hw/kdrive/src/kcmap.c b/hw/kdrive/src/kcmap.c
index 4941ad17f..2c33e798a 100644
--- a/hw/kdrive/src/kcmap.c
+++ b/hw/kdrive/src/kcmap.c
@@ -217,7 +217,8 @@ KdUninstallColormap (ColormapPtr pCmap)
return;
/* install default if on same fb */
- defMap = (ColormapPtr) LookupIDByType(defMapID, RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&defMap, defMapID, RT_COLORMAP,
+ serverClient, DixInstallAccess);
if (defMap && KdColormapFb (defMap) == fb)
(*pCmap->pScreen->InstallColormap)(defMap);
else
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index af3e8f1d4..8ab8bae64 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -508,8 +508,10 @@ vfbUninstallColormap(ColormapPtr pmap)
{
if (pmap->mid != pmap->pScreen->defColormap)
{
- curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&curpmap,
+ pmap->pScreen->defColormap,
+ RT_COLORMAP, serverClient,
+ DixInstallAccess);
(*pmap->pScreen->InstallColormap)(curpmap);
}
}
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index a627b5315..7e73bb85c 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -211,8 +211,8 @@ Bool xf86HandleColormaps(
ComputeGamma(pScreenPriv);
/* get the default map */
-
- pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixInstallAccess);
if(!CMapAllocateColormapPrivate(pDefMap)) {
CMapUnwrapScreen(pScreen);
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 868fb0624..46aa8b882 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -420,6 +420,7 @@ static int
ProcXDGAInstallColormap(ClientPtr client)
{
ColormapPtr cmap;
+ int rc;
REQUEST(xXDGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens)
@@ -430,13 +431,13 @@ ProcXDGAInstallColormap(ClientPtr client)
REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
- cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP);
- if (cmap) {
+ rc = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc == Success) {
DGAInstallCmap(cmap);
return (client->noClientException);
} else {
- client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
return (client->noClientException);
@@ -858,6 +859,7 @@ static int
ProcXF86DGAInstallColormap(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xXF86DGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens)
@@ -871,13 +873,13 @@ ProcXF86DGAInstallColormap(ClientPtr client)
if (!DGAActive(stuff->screen))
return (DGAErrorBase + XF86DGADirectNotActivated);
- pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP);
- if (pcmp) {
+ rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc == Success) {
DGAInstallCmap(pcmp);
return (client->noClientException);
} else {
- client->errorValue = stuff->id;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index c01686de3..3af9878d5 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1363,11 +1363,12 @@ Bool
DRIDrawablePrivDelete(pointer pResource, XID id)
{
WindowPtr pWin;
+ int rc;
id = (XID)pResource;
- pWin = LookupIDByType(id, RT_WINDOW);
+ rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess);
- if (pWin) {
+ if (rc == Success) {
DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
if (!pDRIDrwPriv)
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 44043c6c7..095e480a3 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -277,8 +277,8 @@ vgaUninstallColormap(pmap)
if ( pmap != miInstalledMaps[pmap->pScreen->myNum] )
return;
- defColormap = (ColormapPtr) LookupIDByType( pmap->pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&defColormap, pmap->pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixInstallAccess);
if (defColormap == miInstalledMaps[pmap->pScreen->myNum])
return;
diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c
index 5ba0bdbad..dc749478f 100644
--- a/hw/xnest/Color.c
+++ b/hw/xnest/Color.c
@@ -242,16 +242,16 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
WindowPtr pWin;
Visual *visual;
ColormapPtr pCmap;
-
+
pWin = xnestWindowPtr(icws.windows[0]);
visual = xnestVisualFromID(pScreen, wVisual(pWin));
if (visual == xnestDefaultVisual(pScreen))
- pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin),
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixUseAccess);
else
- pCmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixUseAccess);
XSetWindowColormap(xnestDisplay,
xnestDefaultWindows[pScreen->myNum],
@@ -302,7 +302,8 @@ xnestDirectInstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) {
ColormapPtr pCmap;
- pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP,
+ serverClient, DixInstallAccess);
if (pCmap)
XInstallColormap(xnestDisplay, xnestColormap(pCmap));
}
@@ -321,7 +322,8 @@ xnestDirectUninstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) {
ColormapPtr pCmap;
- pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP,
+ serverClient, DixUninstallAccess);
if (pCmap)
XUninstallColormap(xnestDisplay, xnestColormap(pCmap));
}
@@ -365,8 +367,10 @@ xnestUninstallColormap(ColormapPtr pCmap)
{
if (pCmap->mid != pCmap->pScreen->defColormap)
{
- pCurCmap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCurCmap,
+ pCmap->pScreen->defColormap,
+ RT_COLORMAP,
+ serverClient, DixInstallAccess);
(*pCmap->pScreen->InstallColormap)(pCurCmap);
}
}
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index ae3487f4a..48c870fac 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -93,7 +93,8 @@ xnestCreateWindow(WindowPtr pWin)
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
mask |= CWColormap;
if (pWin->optional->colormap) {
- pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixUseAccess);
attributes.colormap = xnestColormap(pCmap);
}
else
@@ -104,7 +105,8 @@ xnestCreateWindow(WindowPtr pWin)
}
else { /* root windows have their own colormaps at creation time */
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
- pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixUseAccess);
mask |= CWColormap;
attributes.colormap = xnestColormap(pCmap);
}
@@ -338,7 +340,8 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (mask & CWColormap) {
ColormapPtr pCmap;
- pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), RT_COLORMAP,
+ serverClient, DixUseAccess);
attributes.colormap = xnestColormap(pCmap);
diff --git a/mi/micmap.c b/mi/micmap.c
index 6318d6745..1d26a5232 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -87,8 +87,10 @@ miUninstallColormap(ColormapPtr pmap)
{
if (pmap->mid != pmap->pScreen->defColormap)
{
- curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
- RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&curpmap,
+ pmap->pScreen->defColormap,
+ RT_COLORMAP, serverClient,
+ DixUseAccess);
(*pmap->pScreen->InstallColormap)(curpmap);
}
}
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 5746a5fca..2c43d9824 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -436,7 +436,7 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
return;
}
realWin = win->info[0].id;
- pWin = LookupIDByType(realWin, RT_WINDOW);
+ dixLookupWindow(&pWin, realWin, serverClient, DixSendAccess);
}
if(x || y || scrnum)
for (i = 0; i < numRects; i++) {
diff --git a/randr/randr.c b/randr/randr.c
index 07dd9e917..fd0a30aa1 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -279,7 +279,8 @@ RRFreeClient (pointer data, XID id)
pRREvent = (RREventPtr) data;
pWin = pRREvent->window;
- pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, RREventType);
+ dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ RREventType, serverClient, DixDestroyAccess);
if (pHead) {
pPrev = 0;
for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next)
@@ -357,7 +358,8 @@ TellChanged (WindowPtr pWin, pointer value)
rrScrPriv(pScreen);
int i;
- pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, RREventType);
+ dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ RREventType, serverClient, DixReadAccess);
if (!pHead)
return WT_WALKCHILDREN;
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 5e70aa3bf..af1437404 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -340,15 +340,29 @@ extern _X_EXPORT RESTYPE RRClientType, RREventType; /* resource types for event
extern _X_EXPORT DevPrivateKey RRClientPrivateKey;
extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
-#define LookupOutput(client,id,a) ((RROutputPtr) \
- (SecurityLookupIDByType (client, id, \
- RROutputType, a)))
-#define LookupCrtc(client,id,a) ((RRCrtcPtr) \
- (SecurityLookupIDByType (client, id, \
- RRCrtcType, a)))
-#define LookupMode(client,id,a) ((RRModePtr) \
- (SecurityLookupIDByType (client, id, \
- RRModeType, a)))
+#define VERIFY_RR_OUTPUT(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((pointer *)&(ptr), id,\
+ RROutputType, client, a);\
+ if (rc != Success)\
+ return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;\
+ }
+
+#define VERIFY_RR_CRTC(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((pointer *)&(ptr), id,\
+ RRCrtcType, client, a);\
+ if (rc != Success)\
+ return (rc == BadValue) ? RRErrorBase + BadRRCrtc : rc;\
+ }
+
+#define VERIFY_RR_MODE(id, ptr, a)\
+ {\
+ int rc = dixLookupResourceByType((pointer *)&(ptr), id,\
+ RRModeType, client, a);\
+ if (rc != Success)\
+ return (rc == BadValue) ? RRErrorBase + BadRRMode : rc;\
+ }
#define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 7b724aefc..287c21194 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -658,10 +658,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
BoxRec panned_area;
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
- crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
-
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
/* All crtcs must be associated with screens before client
* requests are processed
@@ -775,17 +772,13 @@ ProcRRSetCrtcConfig (ClientPtr client)
TimeStamp configTime;
TimeStamp time;
Rotation rotation;
- int i, j;
+ int rc, i, j;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
- crtc = LookupIDByType (stuff->crtc, RRCrtcType);
- if (!crtc)
- {
- client->errorValue = stuff->crtc;
- return RRErrorBase + BadRRCrtc;
- }
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);
+
if (stuff->mode == None)
{
mode = NULL;
@@ -794,12 +787,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
}
else
{
- mode = LookupIDByType (stuff->mode, RRModeType);
- if (!mode)
- {
- client->errorValue = stuff->mode;
- return RRErrorBase + BadRRMode;
- }
+ VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess);
if (numOutputs == 0)
return BadMatch;
}
@@ -815,13 +803,13 @@ ProcRRSetCrtcConfig (ClientPtr client)
outputIds = (RROutput *) (stuff + 1);
for (i = 0; i < numOutputs; i++)
{
- outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType);
- if (!outputs[i])
+ rc = dixLookupResourceByType((pointer *)(outputs + i), outputIds[i],
+ RROutputType, client, DixSetAttrAccess);
+ if (rc != Success)
{
- client->errorValue = outputIds[i];
if (outputs)
xfree (outputs);
- return RRErrorBase + BadRROutput;
+ return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;
}
/* validate crtc for this output */
for (j = 0; j < outputs[i]->numCrtcs; j++)
@@ -1027,10 +1015,7 @@ ProcRRGetPanning (ClientPtr client)
int n;
REQUEST_SIZE_MATCH(xRRGetPanningReq);
- crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
-
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
/* All crtcs must be associated with screens before client
* requests are processed
@@ -1100,11 +1085,7 @@ ProcRRSetPanning (ClientPtr client)
int n;
REQUEST_SIZE_MATCH(xRRSetPanningReq);
- crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
-
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
-
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
/* All crtcs must be associated with screens before client
* requests are processed
@@ -1175,9 +1156,7 @@ ProcRRGetCrtcGammaSize (ClientPtr client)
int n;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
- crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
/* Gamma retrieval failed, any better error? */
if (!RRCrtcGammaGet(crtc))
@@ -1207,9 +1186,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
char *extra = NULL;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
- crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
/* Gamma retrieval failed, any better error? */
if (!RRCrtcGammaGet(crtc))
@@ -1252,9 +1229,7 @@ ProcRRSetCrtcGamma (ClientPtr client)
CARD16 *red, *green, *blue;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
- crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2);
if (len < (stuff->size * 3 + 1) >> 1)
@@ -1287,9 +1262,7 @@ ProcRRSetCrtcTransform (ClientPtr client)
int nparams;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
- crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
PictTransform_from_xRenderTransform (&transform, &stuff->transform);
pixman_f_transform_from_pixman_transform (&f_transform, &transform);
@@ -1372,9 +1345,7 @@ ProcRRGetCrtcTransform (ClientPtr client)
char *extra;
REQUEST_SIZE_MATCH (xRRGetCrtcTransformReq);
- crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
- if (!crtc)
- return RRErrorBase + BadRRCrtc;
+ VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
pending = &crtc->client_pending_transform;
current = &crtc->client_current_transform;
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 0925875bf..bec5b08af 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -79,9 +79,10 @@ ProcRRSelectInput (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success)
return rc;
- pHead = (RREventPtr *)SecurityLookupIDByType(client,
- pWin->drawable.id, RREventType,
- DixWriteAccess);
+ rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ RREventType, client, DixWriteAccess);
+ if (rc != Success && rc != BadValue)
+ return rc;
if (stuff->enable & (RRScreenChangeNotifyMask|
RRCrtcChangeNotifyMask|
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 2fa440385..2a1007662 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -332,12 +332,8 @@ ProcRRDestroyMode (ClientPtr client)
RRModePtr mode;
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
- mode = LookupIDByType (stuff->mode, RRModeType);
- if (!mode)
- {
- client->errorValue = stuff->mode;
- return RRErrorBase + BadRRMode;
- }
+ VERIFY_RR_MODE(stuff->mode, mode, DixDestroyAccess);
+
if (!mode->userScreen)
return BadMatch;
if (mode->refcnt > 1)
@@ -354,20 +350,8 @@ ProcRRAddOutputMode (ClientPtr client)
RROutputPtr output;
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
- output = LookupOutput(client, stuff->output, DixReadAccess);
-
- if (!output)
- {
- client->errorValue = stuff->output;
- return RRErrorBase + BadRROutput;
- }
-
- mode = LookupIDByType (stuff->mode, RRModeType);
- if (!mode)
- {
- client->errorValue = stuff->mode;
- return RRErrorBase + BadRRMode;
- }
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
+ VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
return RROutputAddUserMode (output, mode);
}
@@ -380,20 +364,8 @@ ProcRRDeleteOutputMode (ClientPtr client)
RROutputPtr output;
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
- output = LookupOutput(client, stuff->output, DixReadAccess);
-
- if (!output)
- {
- client->errorValue = stuff->output;
- return RRErrorBase + BadRROutput;
- }
-
- mode = LookupIDByType (stuff->mode, RRModeType);
- if (!mode)
- {
- client->errorValue = stuff->mode;
- return RRErrorBase + BadRRMode;
- }
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
+ VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
return RROutputDeleteUserMode (output, mode);
}
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 0ae7873e2..127497eb8 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -448,13 +448,7 @@ ProcRRGetOutputInfo (ClientPtr client)
int i, n;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
- output = LookupOutput(client, stuff->output, DixReadAccess);
-
- if (!output)
- {
- client->errorValue = stuff->output;
- return RRErrorBase + BadRROutput;
- }
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
pScreen = output->pScreen;
pScrPriv = rrGetScrPriv(pScreen);
@@ -569,24 +563,16 @@ ProcRRSetOutputPrimary(ClientPtr client)
RROutputPtr output = NULL;
WindowPtr pWin;
rrScrPrivPtr pScrPriv;
+ int rc;
REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
- pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
- DixReadAccess);
-
- if (!pWin) {
- client->errorValue = stuff->window;
- return BadWindow;
- }
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
if (stuff->output) {
- output = LookupOutput(client, stuff->output, DixReadAccess);
-
- if (!output) {
- client->errorValue = stuff->output;
- return RRErrorBase + BadRROutput;
- }
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (output->pScreen != pWin->drawable.pScreen) {
client->errorValue = stuff->window;
@@ -608,16 +594,13 @@ ProcRRGetOutputPrimary(ClientPtr client)
rrScrPrivPtr pScrPriv;
xRRGetOutputPrimaryReply rep;
RROutputPtr primary = NULL;
+ int rc;
REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
- pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
- DixReadAccess);
-
- if (!pWin) {
- client->errorValue = stuff->window;
- return BadWindow;
- }
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
if (pScrPriv)
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 12923a2c7..775d9e29f 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -31,7 +31,8 @@ DeliverPropertyEvent(WindowPtr pWin, void *value)
RREventPtr *pHead, pRREvent;
ClientPtr client;
- pHead = LookupIDByType(pWin->drawable.id, RREventType);
+ dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
+ RREventType, serverClient, DixReadAccess);
if (!pHead)
return WT_WALKCHILDREN;
@@ -419,10 +420,7 @@ ProcRRListOutputProperties (ClientPtr client)
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
- output = LookupOutput (client, stuff->output, DixReadAccess);
-
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
for (prop = output->properties; prop; prop = prop->next)
numProps++;
@@ -466,10 +464,7 @@ ProcRRQueryOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
- output = LookupOutput (client, stuff->output, DixReadAccess);
-
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
prop = RRQueryOutputProperty (output, stuff->property);
if (!prop)
@@ -513,10 +508,7 @@ ProcRRConfigureOutputProperty (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq);
- output = LookupOutput (client, stuff->output, DixReadAccess);
-
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2);
return RRConfigureOutputProperty (output, stuff->property,
@@ -558,9 +550,7 @@ ProcRRChangeOutputProperty (ClientPtr client)
totalSize = len * sizeInBytes;
REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize);
- output = LookupOutput (client, stuff->output, DixWriteAccess);
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!ValidAtom(stuff->property))
{
@@ -590,9 +580,7 @@ ProcRRDeleteOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
UpdateCurrentTime();
- output = LookupOutput (client, stuff->output, DixWriteAccess);
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!ValidAtom(stuff->property))
{
@@ -619,11 +607,8 @@ ProcRRGetOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
if (stuff->delete)
UpdateCurrentTime();
- output = LookupOutput (client, stuff->output,
- stuff->delete ? DixWriteAccess :
- DixReadAccess);
- if (!output)
- return RRErrorBase + BadRROutput;
+ VERIFY_RR_OUTPUT(stuff->output, output,
+ stuff->delete ? DixWriteAccess : DixReadAccess);
if (!ValidAtom(stuff->property))
{
diff --git a/record/record.c b/record/record.c
index f97626f73..cb7a6276c 100644
--- a/record/record.c
+++ b/record/record.c
@@ -127,11 +127,10 @@ static int numEnabledRCAPs;
* returns an error.
*/
#define VERIFY_CONTEXT(_pContext, _contextid, _client) { \
- (_pContext) = (RecordContextPtr)LookupIDByType((_contextid), RTContext); \
- if (!(_pContext)) { \
- (_client)->errorValue = (_contextid); \
- return RecordErrorBase + XRecordBadContext; \
- } \
+ int rc = dixLookupResourceByType((pointer *)&(_pContext), _contextid, \
+ RTContext, _client, DixUseAccess); \
+ if (rc != Success) \
+ return (rc == BadValue) ? RecordErrorBase + XRecordBadContext : rc; \
}
static int RecordDeleteContext(
diff --git a/render/picture.c b/render/picture.c
index 462125f05..5f86c7ce1 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -410,8 +410,9 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
return TRUE;
if (format->index.vid == pScreen->rootVisual) {
- format->index.pColormap =
- (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&format->index.pColormap,
+ pScreen->defColormap, RT_COLORMAP,
+ serverClient, DixGetAttrAccess);
} else {
VisualPtr pVisual = PictureFindVisual(pScreen, format->index.vid);
if (CreateColormap(FakeClientID (0), pScreen, pVisual,
diff --git a/render/picturestr.h b/render/picturestr.h
index 194db11a3..6a1cc061c 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -409,11 +409,10 @@ extern _X_EXPORT RESTYPE GlyphSetType;
#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
- pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
- if (!pPicture) { \
- client->errorValue = pid; \
- return err; \
- } \
+ int rc = dixLookupResourceByType((pointer)&(pPicture), pid,\
+ PictureType, client, mode);\
+ if (rc != Success)\
+ return (rc == BadValue) ? err : rc;\
}
#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
diff --git a/render/render.c b/render/render.c
index 270b8fb29..8487b60de 100644
--- a/render/render.c
+++ b/render/render.c
@@ -509,7 +509,7 @@ static int
ProcRenderQueryPictIndexValues (ClientPtr client)
{
PictFormatPtr pFormat;
- int num;
+ int rc, num;
int rlength;
int i, n;
REQUEST(xRenderQueryPictIndexValuesReq);
@@ -518,16 +518,11 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
- if (!pFormat)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
if (pFormat->type != PictTypeIndexed)
{
client->errorValue = stuff->format;
@@ -592,15 +587,11 @@ ProcRenderCreatePicture (ClientPtr client)
if (rc != Success)
return rc;
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+
if (pFormat->depth != pDrawable->depth)
return BadMatch;
len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2);
@@ -740,7 +731,7 @@ ProcRenderScale (ClientPtr client)
static int
ProcRenderTrapezoids (ClientPtr client)
{
- int ntraps;
+ int rc, ntraps;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrapezoidsReq);
@@ -761,15 +752,10 @@ ProcRenderTrapezoids (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -787,7 +773,7 @@ ProcRenderTrapezoids (ClientPtr client)
static int
ProcRenderTriangles (ClientPtr client)
{
- int ntris;
+ int rc, ntris;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -808,15 +794,10 @@ ProcRenderTriangles (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -834,7 +815,7 @@ ProcRenderTriangles (ClientPtr client)
static int
ProcRenderTriStrip (ClientPtr client)
{
- int npoints;
+ int rc, npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -855,15 +836,10 @@ ProcRenderTriStrip (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -881,7 +857,7 @@ ProcRenderTriStrip (ClientPtr client)
static int
ProcRenderTriFan (ClientPtr client)
{
- int npoints;
+ int rc, npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -902,15 +878,10 @@ ProcRenderTriFan (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -954,15 +925,11 @@ ProcRenderCreateGlyphSet (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
LEGAL_NEW_RESOURCE(stuff->gsid, client);
- format = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
- if (!format)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&format, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+
switch (format->depth) {
case 1:
f = GlyphFormat1;
@@ -1300,7 +1267,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
int nlist;
int space;
int size;
- int n;
+ int rc, n;
REQUEST(xRenderCompositeGlyphsReq);
@@ -1327,28 +1294,18 @@ ProcRenderCompositeGlyphs (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixUseAccess);
- if (!glyphSet)
- {
- client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
- }
+ rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset,
+ GlyphSetType, client, DixUseAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
buffer = (CARD8 *) (stuff + 1);
end = (CARD8 *) stuff + (client->req_len << 2);
@@ -1402,18 +1359,16 @@ ProcRenderCompositeGlyphs (ClientPtr client)
if (buffer + sizeof (GlyphSet) < end)
{
memcpy(&gs, buffer, sizeof(GlyphSet));
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- gs,
- GlyphSetType,
- DixUseAccess);
- if (!glyphSet)
+ rc = dixLookupResourceByType((pointer *)&glyphSet, gs,
+ GlyphSetType, client,
+ DixUseAccess);
+ if (rc != Success)
{
- client->errorValue = gs;
if (glyphsBase != glyphsLocal)
xfree (glyphsBase);
if (listsBase != listsLocal)
xfree (listsBase);
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
}
buffer += 4;
@@ -1902,13 +1857,12 @@ ProcRenderCreateAnimCursor (ClientPtr client)
elt = (xAnimCursorElt *) (stuff + 1);
for (i = 0; i < ncursor; i++)
{
- cursors[i] = (CursorPtr)SecurityLookupIDByType(client, elt->cursor,
- RT_CURSOR, DixReadAccess);
- if (!cursors[i])
+ ret = dixLookupResourceByType((pointer *)(cursors + 1), elt->cursor,
+ RT_CURSOR, client, DixReadAccess);
+ if (ret != Success)
{
xfree (cursors);
- client->errorValue = elt->cursor;
- return BadCursor;
+ return (ret == BadValue) ? BadCursor : ret;
}
deltas[i] = elt->delay;
elt++;
@@ -2689,11 +2643,10 @@ SProcRenderDispatch (ClientPtr client)
#include "panoramiXsrv.h"
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\
- pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\
- if (!pPicture) { \
- client->errorValue = pid; \
- return err; \
- } \
+ int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
+ XRT_PICTURE, client, mode);\
+ if (rc != Success)\
+ return (rc == BadValue) ? err : rc;\
}
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\
@@ -2713,12 +2666,13 @@ PanoramiXRenderCreatePicture (ClientPtr client)
{
REQUEST(xRenderCreatePictureReq);
PanoramiXRes *refDraw, *newPict;
- int result = Success, j;
+ int result, j;
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
- if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index eb83cfeb7..6fa2dff8e 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -203,6 +203,8 @@ XFixesSelectCursorInput (ClientPtr pClient,
CARD32 eventMask)
{
CursorEventPtr *prev, e;
+ pointer val;
+ int rc;
for (prev = &cursorEvents; (e = *prev); prev = &e->next)
{
@@ -235,7 +237,10 @@ XFixesSelectCursorInput (ClientPtr pClient,
* Add a resource hanging from the window to
* catch window destroy
*/
- if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
+ rc = dixLookupResourceByType( &val, pWindow->drawable.id,
+ CursorWindowType, serverClient,
+ DixGetAttrAccess);
+ if (rc != Success)
if (!AddResource (pWindow->drawable.id, CursorWindowType,
(pointer) pWindow))
{
diff --git a/xfixes/select.c b/xfixes/select.c
index 795b8bd4c..a5811bdc0 100644
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -133,6 +133,7 @@ XFixesSelectSelectionInput (ClientPtr pClient,
WindowPtr pWindow,
CARD32 eventMask)
{
+ pointer val;
int rc;
SelectionEventPtr *prev, e;
@@ -173,7 +174,10 @@ XFixesSelectSelectionInput (ClientPtr pClient,
* Add a resource hanging from the window to
* catch window destroy
*/
- if (!LookupIDByType(pWindow->drawable.id, SelectionWindowType))
+ rc = dixLookupResourceByType (&val, pWindow->drawable.id,
+ SelectionWindowType, serverClient,
+ DixGetAttrAccess);
+ if (rc != Success)
if (!AddResource (pWindow->drawable.id, SelectionWindowType,
(pointer) pWindow))
{