Commit 25d5e0a6 authored by Eamon Walsh's avatar Eamon Walsh Committed by Eamon Walsh

Convert callers of SecurityLookupWindow() to dixLookupWindow().

parent 04c72185
......@@ -577,19 +577,17 @@ int PanoramiXTranslateCoords(ClientPtr client)
{
INT16 x, y;
REQUEST(xTranslateCoordsReq);
register WindowPtr pWin, pDst;
int rc;
WindowPtr pWin, pDst;
xTranslateCoordsReply rep;
REQUEST_SIZE_MATCH(xTranslateCoordsReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
DixReadAccess);
if (!pWin)
return(BadWindow);
pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
DixReadAccess);
if (!pDst)
return(BadWindow);
rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
if (rc != Success)
return rc;
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
if (rc != Success)
return rc;
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
......
......@@ -419,12 +419,13 @@ ProcShapeMask (client)
RegionPtr *destRgn;
PixmapPtr pPixmap;
CreateDftPtr createDefault;
int rc;
REQUEST_SIZE_MATCH (xShapeMaskReq);
UpdateCurrentTime();
pWin = SecurityLookupWindow (stuff->dest, client, DixWriteAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->dest, client, DixWriteAccess);
if (rc != Success)
return rc;
switch (stuff->destKind) {
case ShapeBounding:
createDefault = CreateBoundingShape;
......@@ -822,11 +823,12 @@ ProcShapeSelectInput (client)
WindowPtr pWin;
ShapeEventPtr pShapeEvent, pNewShapeEvent, *pHead;
XID clientResource;
int rc;
REQUEST_SIZE_MATCH (xShapeSelectInputReq);
pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (rc != Success)
return rc;
pHead = (ShapeEventPtr *)SecurityLookupIDByType(client,
pWin->drawable.id, EventType, DixWriteAccess);
switch (stuff->enable) {
......
......@@ -1852,9 +1852,10 @@ ProcXpStartPage(ClientPtr client)
if(pContext->state & PAGE_STARTED)
return XpErrorBase+XPBadSequence;
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
DixWriteAccess);
if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum)
result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (result != Success)
return result;
if (pWin->drawable.pScreen->myNum != pContext->screenNum)
return BadWindow;
if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL)
......
......@@ -405,11 +405,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
/* The window must be valid. */
if (!(pWin = SecurityLookupWindow(stuff->window, client,
DixWriteAccess)))
{
return(BadWindow);
}
status = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (status != Success)
return status;
/* The window must be InputOutput. */
if (pWin->drawable.class != InputOutput)
......@@ -729,11 +727,11 @@ ProcDbeSwapBuffers(ClientPtr client)
/* Check all windows to swap. */
/* Each window must be a valid window - BadWindow. */
if (!(pWin = SecurityLookupWindow(dbeSwapInfo[i].window, client,
DixWriteAccess)))
{
error = dixLookupWindow(&pWin, dbeSwapInfo[i].window, client,
DixWriteAccess);
if (error != Success) {
DEALLOCATE_LOCAL(swapInfo);
return(BadWindow);
return error;
}
/* Each window must be double-buffered - BadMatch. */
......
......@@ -1840,16 +1840,16 @@ ProcGetMotionEvents(ClientPtr client)
WindowPtr pWin;
xTimecoord * coords = (xTimecoord *) NULL;
xGetMotionEventsReply rep;
int i, count, xmin, xmax, ymin, ymax;
int i, count, xmin, xmax, ymin, ymax, rc;
unsigned long nEvents;
DeviceIntPtr mouse = inputInfo.pointer;
TimeStamp start, stop;
REQUEST(xGetMotionEventsReq);
REQUEST_SIZE_MATCH(xGetMotionEventsReq);
pWin = SecurityLookupWindow(stuff->window, client, TRUE);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
if (rc != Success)
return rc;
if (mouse->valuator->motionHintWindow)
MaybeStopHint(mouse, client);
rep.type = X_Reply;
......
This diff is collapsed.
......@@ -2228,16 +2228,15 @@ static int
XineramaWarpPointer(ClientPtr client)
{
WindowPtr dest = NULL;
int x, y;
int x, y, rc;
REQUEST(xWarpPointerReq);
if (stuff->dstWid != None)
{
dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess);
if (!dest)
return BadWindow;
if (stuff->dstWid != None) {
rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
if (rc != Success)
return rc;
}
x = sprite.hotPhys.x;
y = sprite.hotPhys.y;
......@@ -2248,8 +2247,9 @@ XineramaWarpPointer(ClientPtr client)
XID winID = stuff->srcWid;
WindowPtr source;
source = SecurityLookupWindow(winID, client, DixReadAccess);
if (!source) return BadWindow;
rc = dixLookupWindow(&source, winID, client, DixReadAccess);
if (rc != Success)
return rc;
winX = source->drawable.x;
winY = source->drawable.y;
......@@ -2301,7 +2301,7 @@ int
ProcWarpPointer(ClientPtr client)
{
WindowPtr dest = NULL;
int x, y;
int x, y, rc;
ScreenPtr newScreen;
REQUEST(xWarpPointerReq);
......@@ -2313,11 +2313,10 @@ ProcWarpPointer(ClientPtr client)
return XineramaWarpPointer(client);
#endif
if (stuff->dstWid != None)
{
dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess);
if (!dest)
return BadWindow;
if (stuff->dstWid != None) {
rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
if (rc != Success)
return rc;
}
x = sprite.hotPhys.x;
y = sprite.hotPhys.y;
......@@ -2328,8 +2327,9 @@ ProcWarpPointer(ClientPtr client)
XID winID = stuff->srcWid;
WindowPtr source;
source = SecurityLookupWindow(winID, client, DixReadAccess);
if (!source) return BadWindow;
rc = dixLookupWindow(&source, winID, client, DixReadAccess);
if (rc != Success)
return rc;
winX = source->drawable.x;
winY = source->drawable.y;
......@@ -3532,8 +3532,8 @@ SetInputFocus(
Bool followOK)
{
register FocusClassPtr focus;
register WindowPtr focusWin;
int mode;
WindowPtr focusWin;
int mode, rc;
TimeStamp time;
UpdateCurrentTime();
......@@ -3550,14 +3550,12 @@ SetInputFocus(
focusWin = (WindowPtr)(long)focusID;
else if ((focusID == FollowKeyboard) && followOK)
focusWin = inputInfo.keyboard->focus->win;
else if (!(focusWin = SecurityLookupWindow(focusID, client,
DixReadAccess)))
return BadWindow;
else
{
else {
rc = dixLookupWindow(&focusWin, focusID, client, DixReadAccess);
if (rc != Success)
return rc;
/* It is a match error to try to set the input focus to an
unviewable window. */
if(!focusWin->realized)
return(BadMatch);
}
......@@ -3646,6 +3644,7 @@ ProcGrabPointer(ClientPtr client)
CursorPtr cursor, oldCursor;
REQUEST(xGrabPointerReq);
TimeStamp time;
int rc;
REQUEST_SIZE_MATCH(xGrabPointerReq);
UpdateCurrentTime();
......@@ -3671,17 +3670,17 @@ ProcGrabPointer(ClientPtr client)
client->errorValue = stuff->eventMask;
return BadValue;
}
pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
if (stuff->confineTo == None)
confineTo = NullWindow;
else
{
confineTo = SecurityLookupWindow(stuff->confineTo, client,
DixReadAccess);
if (!confineTo)
return BadWindow;
rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
DixReadAccess);
if (rc != Success)
return rc;
}
if (stuff->cursor == None)
cursor = NullCursor;
......@@ -3812,9 +3811,10 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev,
unsigned this_mode, unsigned other_mode, Window grabWindow,
unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status)
{
register WindowPtr pWin;
WindowPtr pWin;
register GrabPtr grab;
TimeStamp time;
int rc;
UpdateCurrentTime();
if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync))
......@@ -3832,9 +3832,9 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev,
client->errorValue = ownerEvents;
return BadValue;
}
pWin = SecurityLookupWindow(grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
time = ClientTimeToServerTime(ctime);
grab = dev->grab;
if (grab && !SameClient(grab, client))
......@@ -3918,11 +3918,12 @@ ProcQueryPointer(ClientPtr client)
WindowPtr pWin, t;
REQUEST(xResourceReq);
DeviceIntPtr mouse = inputInfo.pointer;
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
pWin = SecurityLookupWindow(stuff->id, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
if (rc != Success)
return rc;
if (mouse->valuator->motionHintWindow)
MaybeStopHint(mouse, client);
rep.type = X_Reply;
......@@ -4086,8 +4087,8 @@ ProcSendEvent(ClientPtr client)
effectiveFocus = pWin = inputFocus;
}
else
pWin = SecurityLookupWindow(stuff->destination, client,
DixReadAccess);
dixLookupWindow(&pWin, stuff->destination, client, DixReadAccess);
if (!pWin)
return BadWindow;
if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
......@@ -4123,11 +4124,12 @@ ProcUngrabKey(ClientPtr client)
WindowPtr pWin;
GrabRec tempGrab;
DeviceIntPtr keybd = inputInfo.keyboard;
int rc;
REQUEST_SIZE_MATCH(xUngrabKeyReq);
pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
(stuff->key < keybd->key->curKeySyms.minKeyCode))
......@@ -4164,6 +4166,7 @@ ProcGrabKey(ClientPtr client)
REQUEST(xGrabKeyReq);
GrabPtr grab;
DeviceIntPtr keybd = inputInfo.keyboard;
int rc;
REQUEST_SIZE_MATCH(xGrabKeyReq);
if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse))
......@@ -4196,9 +4199,9 @@ ProcGrabKey(ClientPtr client)
client->errorValue = stuff->modifiers;
return BadValue;
}
pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
grab = CreateGrab(client->index, keybd, pWin,
(Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
......@@ -4218,6 +4221,7 @@ ProcGrabButton(ClientPtr client)
REQUEST(xGrabButtonReq);
CursorPtr cursor;
GrabPtr grab;
int rc;
REQUEST_SIZE_MATCH(xGrabButtonReq);
if ((stuff->pointerMode != GrabModeSync) &&
......@@ -4248,16 +4252,16 @@ ProcGrabButton(ClientPtr client)
client->errorValue = stuff->eventMask;
return BadValue;
}
pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
if (stuff->confineTo == None)
confineTo = NullWindow;
else {
confineTo = SecurityLookupWindow(stuff->confineTo, client,
DixReadAccess);
if (!confineTo)
return BadWindow;
rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
DixReadAccess);
if (rc != Success)
return rc;
}
if (stuff->cursor == None)
cursor = NullCursor;
......@@ -4289,6 +4293,7 @@ ProcUngrabButton(ClientPtr client)
REQUEST(xUngrabButtonReq);
WindowPtr pWin;
GrabRec tempGrab;
int rc;
REQUEST_SIZE_MATCH(xUngrabButtonReq);
if ((stuff->modifiers != AnyModifier) &&
......@@ -4297,9 +4302,9 @@ ProcUngrabButton(ClientPtr client)
client->errorValue = stuff->modifiers;
return BadValue;
}
pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
return rc;
tempGrab.resource = client->clientAsMask;
tempGrab.device = inputInfo.pointer;
tempGrab.window = pWin;
......
......@@ -94,7 +94,7 @@ PrintPropertys(WindowPtr pWin)
int
ProcRotateProperties(ClientPtr client)
{
int i, j, delta;
int i, j, delta, rc;
REQUEST(xRotatePropertiesReq);
WindowPtr pWin;
register Atom * atoms;
......@@ -104,10 +104,9 @@ ProcRotateProperties(ClientPtr client)
REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
UpdateCurrentTime();
pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
DixWriteAccess);
if (!pWin)
return(BadWindow);
rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (rc != Success)
return rc;
if (!stuff->nAtoms)
return(Success);
atoms = (Atom *) & stuff[1];
......@@ -181,9 +180,7 @@ ProcChangeProperty(ClientPtr client)
WindowPtr pWin;
char format, mode;
unsigned long len;
int sizeInBytes;
int totalSize;
int err;
int sizeInBytes, totalSize, err;
REQUEST(xChangePropertyReq);
REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
......@@ -208,10 +205,9 @@ ProcChangeProperty(ClientPtr client)
totalSize = len * sizeInBytes;
REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
DixWriteAccess);
if (!pWin)
return(BadWindow);
err = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (err != Success)
return err;
if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
......@@ -445,7 +441,7 @@ int
ProcGetProperty(ClientPtr client)
{
PropertyPtr pProp, prevProp;
unsigned long n, len, ind;
unsigned long n, len, ind, rc;
WindowPtr pWin;
xGetPropertyReply reply;
Mask access_mode = DixReadAccess;
......@@ -454,10 +450,9 @@ ProcGetProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xGetPropertyReq);
if (stuff->delete)
UpdateCurrentTime();
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
DixReadAccess);
if (!pWin)
return BadWindow;
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
if (rc != Success)
return rc;
if (!ValidAtom(stuff->property))
{
......@@ -585,16 +580,15 @@ ProcListProperties(ClientPtr client)
{
Atom *pAtoms = NULL, *temppAtoms;
xListPropertiesReply xlpr;
int numProps = 0;
int rc, numProps = 0;
WindowPtr pWin;
PropertyPtr pProp;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
DixReadAccess);
if (!pWin)
return(BadWindow);
rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
if (rc != Success)
return rc;
pProp = wUserProps (pWin);
while (pProp)
......@@ -636,10 +630,9 @@ ProcDeleteProperty(register ClientPtr client)
REQUEST_SIZE_MATCH(xDeletePropertyReq);
UpdateCurrentTime();
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
DixWriteAccess);
if (!pWin)
return(BadWindow);
result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (result != Success)
return result;
if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
......
......@@ -490,11 +490,9 @@ ProcAppleWMSetWindowLevel(
REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
client, DixReadAccess)))
{
if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue;
}
if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) {
return BadValue;
......@@ -602,11 +600,9 @@ ProcAppleWMFrameDraw(
REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
client, DixReadAccess)))
{
if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue;
}
ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
......
......@@ -286,8 +286,8 @@ static int ProcDMXForceWindowCreation(ClientPtr client)
return -1; /* BadWindow */
FOR_NSCREENS(i) {
if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
DixReadAccess)))
if (Success != dixLookupWindow(&pWin, win->info[i].id, client,
DixReadAccess))
return -1; /* BadWindow */
dmxForceWindowCreation(pWin);
......@@ -296,8 +296,8 @@ static int ProcDMXForceWindowCreation(ClientPtr client)
}
#endif
if (!(pWin = SecurityLookupWindow(stuff->window, client,
DixReadAccess)))
if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return -1; /* BadWindow */
dmxForceWindowCreation(pWin);
......@@ -560,8 +560,8 @@ static int dmxPopulatePanoramiX(ClientPtr client, Window window,
return -1; /* BadWindow */
FOR_NSCREENS(i) {
if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
DixReadAccess)))
if (Success != dixLookupWindow(&pWin, win->info[i].id, client,
DixReadAccess))
return -1; /* BadWindow */
if (dmxGetWindowAttributes(pWin, &attr)) {
screens[count] = attr.screen;
......@@ -587,7 +587,7 @@ static int dmxPopulate(ClientPtr client, Window window, CARD32 *screens,
pos, vis);
#endif
if (!(pWin = SecurityLookupWindow(window, client, DixReadAccess)))
if (Success != dixLookupWindow(&pWin, window, client, DixReadAccess))
return -1; /* BadWindow */
dmxGetWindowAttributes(pWin, &attr);
......
......@@ -1137,9 +1137,7 @@ static int MakeCurrent(__GLXclientState *cl,
}
#ifdef PANORAMIX
else if (pXinDraw) {
pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
client,
DixReadAccess);
dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
}
#endif
else if (pGlxWindow) {
......@@ -1195,9 +1193,8 @@ static int MakeCurrent(__GLXclientState *cl,
}
#ifdef PANORAMIX
else if (pXinReadDraw) {
pReadWin = (WindowPtr)SecurityLookupWindow(pXinReadDraw->info[s].id,
client,
DixReadAccess);
dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client,
DixReadAccess);
}
#endif
else if (pGlxReadWindow) {
......@@ -2058,9 +2055,7 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
}
#ifdef PANORAMIX
else if (pXinDraw) {
pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
client,
DixReadAccess);
dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
}
#endif
else if (pGlxWindow) {
......@@ -3359,9 +3354,8 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
return __glXBadDrawable;
}
pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
client,
DixReadAccess);
dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
DixReadAccess);
}
#endif
......@@ -3521,9 +3515,8 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
return __glXBadDrawable;
}
pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
client,
DixReadAccess);
dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
DixReadAccess);
}
#endif
......
......@@ -344,13 +344,11 @@ winProcSetSelectionOwner (ClientPtr client)
if (None != stuff->window)
{
/* Grab the Window from the request */
pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client,
DixReadAccess);
if (!pWindow)
{
int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
if (rc != Success) {
ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");