diff options
Diffstat (limited to 'xorg-server/Xext/xvmc.c')
-rw-r--r-- | xorg-server/Xext/xvmc.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/xorg-server/Xext/xvmc.c b/xorg-server/Xext/xvmc.c index ad1b8abc0..b7bb0fc1b 100644 --- a/xorg-server/Xext/xvmc.c +++ b/xorg-server/Xext/xvmc.c @@ -1,6 +1,4 @@ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -138,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; @@ -158,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num = (adaptor) ? adaptor->num_surfaces : 0; - rep.length = rep.num * sizeof(xvmcSurfaceInfo) >> 2; + rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo)); WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep); @@ -194,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; @@ -275,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); @@ -299,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); @@ -339,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); @@ -365,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); @@ -450,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); @@ -477,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; @@ -514,7 +519,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client) if(surface->compatible_subpictures) rep.num = surface->compatible_subpictures->num_xvimages; - rep.length = rep.num * sizeof(xvImageFormatInfo) >> 2; + rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo)); WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep); @@ -573,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); @@ -587,8 +588,8 @@ ProcXvMCGetDRInfo(ClientPtr client) rep.major = pScreenPriv->major; rep.minor = pScreenPriv->minor; rep.patchLevel = pScreenPriv->patchLevel; - rep.nameLen = (strlen(pScreenPriv->clientDriverName) + 4) >> 2; - rep.busIDLen = (strlen(pScreenPriv->busID) + 4) >> 2; + rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1); + rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1); rep.length = rep.nameLen + rep.busIDLen; rep.nameLen <<=2; @@ -664,7 +665,7 @@ SProcXvMCDispatch (ClientPtr client) return BadImplementation; } -void +void XvMCExtensionInit(void) { ExtensionEntry *extEntry; @@ -712,7 +713,7 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) XvMCScreenKey = &XvMCScreenKeyIndex; - if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec)))) + if(!(pScreenPriv = xalloc(sizeof(XvMCScreenRec)))) return BadAlloc; dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv); |