diff options
Diffstat (limited to 'xorg-server/Xext/panoramiXprocs.c')
-rw-r--r-- | xorg-server/Xext/panoramiXprocs.c | 717 |
1 files changed, 398 insertions, 319 deletions
diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 38199a5df..6834efb71 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -32,8 +32,6 @@ Equipment Corporation. #include <stdio.h> #include <X11/X.h> -#define NEED_REPLIES -#define NEED_EVENTS #include <X11/Xproto.h> #include "windowstr.h" #include "dixfontstr.h" @@ -69,20 +67,21 @@ 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; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - len = client->req_len - (sizeof(xCreateWindowReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); 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; @@ -94,31 +93,34 @@ 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; } } - if(!(newWin = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newWin = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newWin->type = XRT_WINDOW; @@ -172,18 +174,19 @@ 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); - len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); 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))) @@ -193,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; } } @@ -235,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; @@ -260,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; @@ -285,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; @@ -307,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; @@ -344,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; @@ -366,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; @@ -388,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; @@ -410,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; @@ -434,33 +449,36 @@ 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); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); if (Ones(stuff->mask) != len) 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; } } @@ -498,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; @@ -636,17 +655,18 @@ 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 = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newPix = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newPix->type = XRT_PIXMAP; @@ -674,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; @@ -707,46 +728,50 @@ 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); client->errorValue = stuff->gc; - len = client->req_len - (sizeof(xCreateGCReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); 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; } } - if(!(newGC = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newGC = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newGC->type = XRT_GC; @@ -783,41 +808,45 @@ 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); - len = client->req_len - (sizeof(xChangeGCReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); 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; } } @@ -841,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; @@ -868,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; @@ -890,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; @@ -912,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; @@ -937,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; @@ -976,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; @@ -985,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; @@ -1141,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; @@ -1237,28 +1278,30 @@ 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; + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); if (npoint > 0) { - origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); + origPts = xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1295,28 +1338,30 @@ 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; + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); if (npoint > 0){ - origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); + origPts = xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1352,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; @@ -1360,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; @@ -1377,7 +1424,7 @@ int PanoramiXPolySegment(ClientPtr client) if(nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs > 0) { - origSegs = (xSegment *) xalloc(nsegs * sizeof(xSegment)); + origSegs = xalloc(nsegs * sizeof(xSegment)); memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); FOR_NSCREENS_FORWARD(j){ @@ -1413,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; @@ -1421,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; @@ -1439,7 +1487,7 @@ int PanoramiXPolyRectangle(ClientPtr client) if(nrects & 4) return BadLength; nrects >>= 3; if (nrects > 0){ - origRecs = (xRectangle *) xalloc(nrects * sizeof(xRectangle)); + origRecs = xalloc(nrects * sizeof(xRectangle)); memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1474,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; @@ -1482,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; @@ -1499,7 +1549,7 @@ int PanoramiXPolyArc(ClientPtr client) if(narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs > 0){ - origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); + origArcs = xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1532,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; @@ -1540,22 +1590,24 @@ 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; - count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; + count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); if (count > 0){ - locPts = (DDXPointPtr) xalloc(count * sizeof(DDXPointRec)); + locPts = xalloc(count * sizeof(DDXPointRec)); memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); FOR_NSCREENS_FORWARD(j){ @@ -1591,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; @@ -1599,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; @@ -1616,7 +1670,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client) if(things & 4) return BadLength; things >>= 3; if (things > 0){ - origRects = (xRectangle *) xalloc(things * sizeof(xRectangle)); + origRects = xalloc(things * sizeof(xRectangle)); memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1652,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; @@ -1675,7 +1731,7 @@ int PanoramiXPolyFillArc(ClientPtr client) IF_RETURN((narcs % sizeof(xArc)), BadLength); narcs /= sizeof(xArc); if (narcs > 0) { - origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); + origArcs = xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1711,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; @@ -1767,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); @@ -1836,7 +1895,7 @@ int PanoramiXGetImage(ClientPtr client) } - xgi.length = (length + 3) >> 2; + xgi.length = bytes_to_int32(length); if (widthBytesLine == 0 || h == 0) linesPerBuf = 0; @@ -1908,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; @@ -1947,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; @@ -1984,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; @@ -1992,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; @@ -2023,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; @@ -2031,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; @@ -2064,16 +2131,17 @@ 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 = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newCmap = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; @@ -2102,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; @@ -2130,19 +2199,20 @@ 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 = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newCmap = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; @@ -2169,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; @@ -2192,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; @@ -2214,7 +2286,7 @@ int PanoramiXUninstallColormap(ClientPtr client) int PanoramiXAllocColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorReq); @@ -2222,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; @@ -2237,7 +2310,7 @@ int PanoramiXAllocColor(ClientPtr client) int PanoramiXAllocNamedColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocNamedColorReq); @@ -2245,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; @@ -2260,7 +2334,7 @@ int PanoramiXAllocNamedColor(ClientPtr client) int PanoramiXAllocColorCells(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorCellsReq); @@ -2268,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; @@ -2283,7 +2358,7 @@ int PanoramiXAllocColorCells(ClientPtr client) int PanoramiXAllocColorPlanes(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorPlanesReq); @@ -2291,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; @@ -2307,7 +2383,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client) int PanoramiXFreeColors(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xFreeColorsReq); @@ -2315,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; @@ -2329,7 +2406,7 @@ int PanoramiXFreeColors(ClientPtr client) int PanoramiXStoreColors(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xStoreColorsReq); @@ -2337,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; @@ -2352,7 +2430,7 @@ int PanoramiXStoreColors(ClientPtr client) int PanoramiXStoreNamedColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xStoreNamedColorReq); @@ -2360,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; |