diff options
Diffstat (limited to 'randr')
-rw-r--r-- | randr/randr.c | 6 | ||||
-rw-r--r-- | randr/randrstr.h | 32 | ||||
-rw-r--r-- | randr/rrcrtc.c | 61 | ||||
-rw-r--r-- | randr/rrdispatch.c | 7 | ||||
-rw-r--r-- | randr/rrmode.c | 40 | ||||
-rw-r--r-- | randr/rroutput.c | 37 | ||||
-rw-r--r-- | randr/rrproperty.c | 33 |
7 files changed, 72 insertions, 144 deletions
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)) { |