Fix most remaining deprecated resource lookups.

Callsites updated to use dixLookupResourceBy{Type,Class}.
TODO: Audit access modes to make sure they reflect the usage.
This commit is contained in:
Eamon Walsh 2009-04-29 01:04:37 -04:00
parent 1abe0ee3da
commit 57aff88c7d
50 changed files with 1015 additions and 1035 deletions

View File

@ -354,9 +354,12 @@ PanoramiXRes *
PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen) PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
{ {
PanoramiXSearchData data; PanoramiXSearchData data;
pointer val;
if(!screen) if(!screen) {
return LookupIDByType(id, type); dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess);
return val;
}
data.screen = screen; data.screen = screen;
data.id = id; data.id = id;

View File

@ -97,6 +97,4 @@ typedef struct {
#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) #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_ */ #endif /* _PANORAMIX_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -533,11 +533,14 @@ UninstallSaverColormap (ScreenPtr pScreen)
{ {
SetupScreen(pScreen); SetupScreen(pScreen);
ColormapPtr pCmap; ColormapPtr pCmap;
int rc;
if (pPriv && pPriv->installedMap != None) if (pPriv && pPriv->installedMap != None)
{ {
pCmap = (ColormapPtr) LookupIDByType (pPriv->installedMap, RT_COLORMAP); rc = dixLookupResourceByType((pointer *)&pCmap, pPriv->installedMap,
if (pCmap) RT_COLORMAP, serverClient,
DixUninstallAccess);
if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap); (*pCmap->pScreen->UninstallColormap) (pCmap);
pPriv->installedMap = None; pPriv->installedMap = None;
CheckScreenPrivate (pScreen); CheckScreenPrivate (pScreen);
@ -651,8 +654,9 @@ CreateSaverWindow (ScreenPtr pScreen)
if (i < numInstalled) if (i < numInstalled)
return TRUE; return TRUE;
pCmap = (ColormapPtr) LookupIDByType (wantMap, RT_COLORMAP); result = dixLookupResourceByType((pointer *)&pCmap, wantMap, RT_COLORMAP,
if (!pCmap) serverClient, DixInstallAccess);
if (result != Success)
return TRUE; return TRUE;
pPriv->installedMap = wantMap; pPriv->installedMap = wantMap;
@ -1252,15 +1256,16 @@ ProcScreenSaverSetAttributes (ClientPtr client)
PanoramiXRes *backPix = NULL; PanoramiXRes *backPix = NULL;
PanoramiXRes *bordPix = NULL; PanoramiXRes *bordPix = NULL;
PanoramiXRes *cmap = NULL; PanoramiXRes *cmap = NULL;
int i, status = 0, len; int i, status, len;
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
XID orig_visual, tmp; XID orig_visual, tmp;
REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( status = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (status != Success)
return (status == BadValue) ? BadDrawable : status;
len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
if (Ones(stuff->mask) != len) if (Ones(stuff->mask) != len)
@ -1270,9 +1275,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset); tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) { if ((tmp != None) && (tmp != ParentRelative)) {
if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( status = dixLookupResourceByType((pointer *)&backPix, tmp,
client, tmp, XRT_PIXMAP, DixReadAccess))) XRT_PIXMAP, client,
return BadPixmap; DixReadAccess);
if (status != Success)
return (status == BadValue) ? BadPixmap : status;
} }
} }
@ -1280,9 +1287,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset); tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) { if (tmp != CopyFromParent) {
if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( status = dixLookupResourceByType((pointer *)&bordPix, tmp,
client, tmp, XRT_PIXMAP, DixReadAccess))) XRT_PIXMAP, client,
return BadPixmap; DixReadAccess);
if (status != Success)
return (status == BadValue) ? BadPixmap : status;
} }
} }
@ -1290,9 +1299,11 @@ ProcScreenSaverSetAttributes (ClientPtr client)
cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset); tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if ((tmp != CopyFromParent) && (tmp != None)) { if ((tmp != CopyFromParent) && (tmp != None)) {
if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( status = dixLookupResourceByType((pointer *)&cmap, tmp,
client, tmp, XRT_COLORMAP, DixReadAccess))) XRT_COLORMAP, client,
return BadColor; DixReadAccess);
if (status != Success)
return (status == BadValue) ? BadColor : status;
} }
} }
@ -1327,11 +1338,12 @@ ProcScreenSaverUnsetAttributes (ClientPtr client)
if(!noPanoramiXExtension) { if(!noPanoramiXExtension) {
REQUEST(xScreenSaverUnsetAttributesReq); REQUEST(xScreenSaverUnsetAttributesReq);
PanoramiXRes *draw; PanoramiXRes *draw;
int i; int rc, i;
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (rc != Success)
return (rc == BadValue) ? BadDrawable : rc;
for(i = PanoramiXNumScreens - 1; i > 0; i--) { for(i = PanoramiXNumScreens - 1; i > 0; i--) {
stuff->drawable = draw->info[i].id; stuff->drawable = draw->info[i].id;

View File

@ -623,13 +623,16 @@ ProcSecurityRevokeAuthorization(
{ {
REQUEST(xSecurityRevokeAuthorizationReq); REQUEST(xSecurityRevokeAuthorizationReq);
SecurityAuthorizationPtr pAuth; SecurityAuthorizationPtr pAuth;
int rc;
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pAuth, stuff->authId,
stuff->authId, SecurityAuthorizationResType, DixDestroyAccess); SecurityAuthorizationResType, client,
if (!pAuth) DixDestroyAccess);
return SecurityErrorBase + XSecurityBadAuthorization; if (rc != Success)
return (rc == BadValue) ?
SecurityErrorBase + XSecurityBadAuthorization : rc;
FreeResource(stuff->authId, RT_NONE); FreeResource(stuff->authId, RT_NONE);
return Success; return Success;

View File

@ -353,13 +353,14 @@ ProcPanoramiXShapeRectangles(
{ {
REQUEST(xShapeRectanglesReq); REQUEST(xShapeRectanglesReq);
PanoramiXRes *win; PanoramiXRes *win;
int j, result = 0; int j, result;
REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
if(!(win = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, stuff->dest, XRT_WINDOW, DixWriteAccess))) client, DixWriteAccess);
return BadWindow; if (result != Success)
return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
@ -451,18 +452,20 @@ ProcPanoramiXShapeMask(
{ {
REQUEST(xShapeMaskReq); REQUEST(xShapeMaskReq);
PanoramiXRes *win, *pmap; PanoramiXRes *win, *pmap;
int j, result = 0; int j, result;
REQUEST_SIZE_MATCH (xShapeMaskReq); REQUEST_SIZE_MATCH (xShapeMaskReq);
if(!(win = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, stuff->dest, XRT_WINDOW, DixWriteAccess))) client, DixWriteAccess);
return BadWindow; if (result != Success)
return (result == BadValue) ? BadWindow : result;
if(stuff->src != None) { if(stuff->src != None) {
if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&pmap, stuff->src,
client, stuff->src, XRT_PIXMAP, DixReadAccess))) XRT_PIXMAP, client, DixReadAccess);
return BadPixmap; if (result != Success)
return (result == BadValue) ? BadPixmap : result;
} else } else
pmap = NULL; pmap = NULL;
@ -579,17 +582,19 @@ ProcPanoramiXShapeCombine(
{ {
REQUEST(xShapeCombineReq); REQUEST(xShapeCombineReq);
PanoramiXRes *win, *win2; PanoramiXRes *win, *win2;
int j, result = 0; int j, result;
REQUEST_AT_LEAST_SIZE (xShapeCombineReq); REQUEST_AT_LEAST_SIZE (xShapeCombineReq);
if(!(win = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, stuff->dest, XRT_WINDOW, DixWriteAccess))) client, DixWriteAccess);
return BadWindow; if (result != Success)
return (result == BadValue) ? BadWindow : result;
if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&win2, stuff->src, XRT_WINDOW,
client, stuff->src, XRT_WINDOW, DixReadAccess))) client, DixReadAccess);
return BadWindow; if (result != Success)
return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
@ -651,13 +656,14 @@ ProcPanoramiXShapeOffset(
{ {
REQUEST(xShapeOffsetReq); REQUEST(xShapeOffsetReq);
PanoramiXRes *win; PanoramiXRes *win;
int j, result = 0; int j, result;
REQUEST_AT_LEAST_SIZE (xShapeOffsetReq); REQUEST_AT_LEAST_SIZE (xShapeOffsetReq);
if(!(win = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
client, stuff->dest, XRT_WINDOW, DixWriteAccess))) client, DixWriteAccess);
return BadWindow; if (result != Success)
return (result == BadValue) ? BadWindow : result;
FOR_NSCREENS(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
@ -740,11 +746,13 @@ ShapeFreeClient (pointer data, XID id)
ShapeEventPtr pShapeEvent; ShapeEventPtr pShapeEvent;
WindowPtr pWin; WindowPtr pWin;
ShapeEventPtr *pHead, pCur, pPrev; ShapeEventPtr *pHead, pCur, pPrev;
int rc;
pShapeEvent = (ShapeEventPtr) data; pShapeEvent = (ShapeEventPtr) data;
pWin = pShapeEvent->window; pWin = pShapeEvent->window;
pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, ShapeEventType); rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
if (pHead) { ShapeEventType, serverClient, DixReadAccess);
if (rc == Success) {
pPrev = 0; pPrev = 0;
for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next) for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next)
pPrev = pCur; pPrev = pCur;
@ -789,8 +797,11 @@ ProcShapeSelectInput (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
pHead = (ShapeEventPtr *)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
pWin->drawable.id, ShapeEventType, DixWriteAccess); ShapeEventType, client, DixWriteAccess);
if (rc != Success && rc != BadValue)
return rc;
switch (stuff->enable) { switch (stuff->enable) {
case xTrue: case xTrue:
if (pHead) { if (pHead) {
@ -879,9 +890,11 @@ SendShapeNotify (WindowPtr pWin, int which)
BoxRec extents; BoxRec extents;
RegionPtr region; RegionPtr region;
BYTE shaped; BYTE shaped;
int rc;
pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, ShapeEventType); rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
if (!pHead) ShapeEventType, serverClient, DixReadAccess);
if (rc != Success)
return; return;
switch (which) { switch (which) {
case ShapeBounding: case ShapeBounding:
@ -958,8 +971,10 @@ ProcShapeInputSelected (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
pHead = (ShapeEventPtr *) SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
pWin->drawable.id, ShapeEventType, DixReadAccess); ShapeEventType, client, DixReadAccess);
if (rc != Success && rc != BadValue)
return rc;
enabled = xFalse; enabled = xFalse;
if (pHead) { if (pHead) {
for (pShapeEvent = *pHead; for (pShapeEvent = *pHead;

View File

@ -144,12 +144,11 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
#define VERIFY_SHMSEG(shmseg,shmdesc,client) \ #define VERIFY_SHMSEG(shmseg,shmdesc,client) \
{ \ { \
shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \ int rc; \
if (!shmdesc) \ rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \
{ \ client, DixReadAccess); \
client->errorValue = shmseg; \ if (rc != Success) \
return BadShmSegCode; \ return (rc == BadValue) ? BadShmSegCode : rc; \
} \
} }
#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \ #define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
@ -513,20 +512,22 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
static int static int
ProcPanoramiXShmPutImage(ClientPtr client) ProcPanoramiXShmPutImage(ClientPtr client)
{ {
int j, result = 0, orig_x, orig_y; int j, result, orig_x, orig_y;
PanoramiXRes *draw, *gc; PanoramiXRes *draw, *gc;
Bool sendEvent, isRoot; Bool sendEvent, isRoot;
REQUEST(xShmPutImageReq); REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq); REQUEST_SIZE_MATCH(xShmPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
client, stuff->gc, XRT_GC, DixReadAccess))) XRT_GC, client, DixReadAccess);
return BadGC; if (result != Success)
return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@ -570,9 +571,10 @@ ProcPanoramiXShmGetImage(ClientPtr client)
return(BadValue); return(BadValue);
} }
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (rc != Success)
return (rc == BadValue) ? BadDrawable : rc;
if (draw->type == XRT_PIXMAP) if (draw->type == XRT_PIXMAP)
return ProcShmGetImage(client); return ProcShmGetImage(client);

View File

@ -1339,16 +1339,14 @@ ProcSyncSetCounter(ClientPtr client)
REQUEST(xSyncSetCounterReq); REQUEST(xSyncSetCounterReq);
SyncCounter *pCounter; SyncCounter *pCounter;
CARD64 newvalue; CARD64 newvalue;
int rc;
REQUEST_SIZE_MATCH(xSyncSetCounterReq); REQUEST_SIZE_MATCH(xSyncSetCounterReq);
pCounter = SecurityLookupIDByType(client, stuff->cid, RTCounter, rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
DixWriteAccess); client, DixWriteAccess);
if (pCounter == NULL) if (rc != Success)
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
client->errorValue = stuff->cid;
return SyncErrorBase + XSyncBadCounter;
}
if (IsSystemCounter(pCounter)) if (IsSystemCounter(pCounter))
{ {
@ -1371,16 +1369,14 @@ ProcSyncChangeCounter(ClientPtr client)
SyncCounter *pCounter; SyncCounter *pCounter;
CARD64 newvalue; CARD64 newvalue;
Bool overflow; Bool overflow;
int rc;
REQUEST_SIZE_MATCH(xSyncChangeCounterReq); REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
pCounter = SecurityLookupIDByType(client, stuff->cid, RTCounter, rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
DixWriteAccess); client, DixWriteAccess);
if (pCounter == NULL) if (rc != Success)
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
client->errorValue = stuff->cid;
return SyncErrorBase + XSyncBadCounter;
}
if (IsSystemCounter(pCounter)) if (IsSystemCounter(pCounter))
{ {
@ -1408,16 +1404,15 @@ ProcSyncDestroyCounter(ClientPtr client)
{ {
REQUEST(xSyncDestroyCounterReq); REQUEST(xSyncDestroyCounterReq);
SyncCounter *pCounter; SyncCounter *pCounter;
int rc;
REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
pCounter = SecurityLookupIDByType(client, stuff->counter, RTCounter, rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
DixDestroyAccess); client, DixDestroyAccess);
if (pCounter == NULL) if (rc != Success)
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
client->errorValue = stuff->counter;
return SyncErrorBase + XSyncBadCounter;
}
if (IsSystemCounter(pCounter)) if (IsSystemCounter(pCounter))
{ {
client->errorValue = stuff->counter; client->errorValue = stuff->counter;
@ -1552,16 +1547,14 @@ ProcSyncQueryCounter(ClientPtr client)
REQUEST(xSyncQueryCounterReq); REQUEST(xSyncQueryCounterReq);
xSyncQueryCounterReply rep; xSyncQueryCounterReply rep;
SyncCounter *pCounter; SyncCounter *pCounter;
int rc;
REQUEST_SIZE_MATCH(xSyncQueryCounterReq); REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
pCounter = SecurityLookupIDByType(client, stuff->counter, RTCounter, rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
DixReadAccess); RTCounter, client, DixReadAccess);
if (pCounter == NULL) if (rc != Success)
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
client->errorValue = stuff->counter;
return SyncErrorBase + XSyncBadCounter;
}
rep.type = X_Reply; rep.type = X_Reply;
rep.length = 0; rep.length = 0;
@ -1682,12 +1675,10 @@ ProcSyncChangeAlarm(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
if (!(pAlarm = SecurityLookupIDByType(client, stuff->alarm, RTAlarm, status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
DixWriteAccess))) client, DixWriteAccess);
{ if (status != Success)
client->errorValue = stuff->alarm; return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
return SyncErrorBase + XSyncBadAlarm;
}
vmask = stuff->valueMask; vmask = stuff->valueMask;
len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2); len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2);
@ -1719,16 +1710,14 @@ ProcSyncQueryAlarm(ClientPtr client)
SyncAlarm *pAlarm; SyncAlarm *pAlarm;
xSyncQueryAlarmReply rep; xSyncQueryAlarmReply rep;
SyncTrigger *pTrigger; SyncTrigger *pTrigger;
int rc;
REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
pAlarm = SecurityLookupIDByType(client, stuff->alarm, RTAlarm, rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
DixReadAccess); client, DixReadAccess);
if (!pAlarm) if (rc != Success)
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
client->errorValue = stuff->alarm;
return SyncErrorBase + XSyncBadAlarm;
}
rep.type = X_Reply; rep.type = X_Reply;
rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2; rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2;
@ -1776,16 +1765,15 @@ ProcSyncQueryAlarm(ClientPtr client)
static int static int
ProcSyncDestroyAlarm(ClientPtr client) ProcSyncDestroyAlarm(ClientPtr client)
{ {
SyncAlarm *pAlarm;
int rc;
REQUEST(xSyncDestroyAlarmReq); REQUEST(xSyncDestroyAlarmReq);
REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
if (!(SecurityLookupIDByType(client, stuff->alarm, RTAlarm, rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
DixDestroyAccess))) client, DixDestroyAccess);
{ return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
client->errorValue = stuff->alarm;
return SyncErrorBase + XSyncBadAlarm;
}
FreeResource(stuff->alarm, RT_NONE); FreeResource(stuff->alarm, RT_NONE);
return client->noClientException; return client->noClientException;

View File

@ -427,15 +427,15 @@ ProcXF86BigfontQueryFont(
} }
#endif #endif
client->errorValue = stuff->id; /* EITHER font or gc */ client->errorValue = stuff->id; /* EITHER font or gc */
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT,
DixGetAttrAccess); client, DixGetAttrAccess);
if (!pFont) { if (!pFont) {
GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, GC *pGC;
DixGetAttrAccess); dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC,
if (!pGC) { client, DixGetAttrAccess);
client->errorValue = stuff->id; if (!pGC)
return BadFont; /* procotol spec says only error is BadFont */ return BadFont; /* procotol spec says only error is BadFont */
}
pFont = pGC->font; pFont = pGC->font;
} }

View File

@ -479,11 +479,7 @@ ProcXvQueryEncodings(ClientPtr client)
REQUEST(xvQueryEncodingsReq); REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq); REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -540,12 +536,7 @@ ProcXvPutVideo(ClientPtr client)
REQUEST_SIZE_MATCH(xvPutVideoReq); REQUEST_SIZE_MATCH(xvPutVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -583,12 +574,7 @@ ProcXvPutStill(ClientPtr client)
REQUEST_SIZE_MATCH(xvPutStillReq); REQUEST_SIZE_MATCH(xvPutStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -626,12 +612,7 @@ ProcXvGetVideo(ClientPtr client)
REQUEST_SIZE_MATCH(xvGetVideoReq); REQUEST_SIZE_MATCH(xvGetVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -669,12 +650,7 @@ ProcXvGetStill(ClientPtr client)
REQUEST_SIZE_MATCH(xvGetStillReq); REQUEST_SIZE_MATCH(xvGetStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -723,11 +699,7 @@ ProcXvSelectPortNotify(ClientPtr client)
REQUEST(xvSelectPortNotifyReq); REQUEST(xvSelectPortNotifyReq);
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -747,11 +719,7 @@ ProcXvGrabPort(ClientPtr client)
REQUEST(xvGrabPortReq); REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -784,11 +752,7 @@ ProcXvUngrabPort(ClientPtr client)
REQUEST(xvGrabPortReq); REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -808,11 +772,7 @@ ProcXvStopVideo(ClientPtr client)
REQUEST(xvStopVideoReq); REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -835,11 +795,7 @@ ProcXvSetPortAttribute(ClientPtr client)
REQUEST(xvSetPortAttributeReq); REQUEST(xvSetPortAttributeReq);
REQUEST_SIZE_MATCH(xvSetPortAttributeReq); REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -873,11 +829,7 @@ ProcXvGetPortAttribute(ClientPtr client)
REQUEST(xvGetPortAttributeReq); REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -918,11 +870,7 @@ ProcXvQueryBestSize(ClientPtr client)
REQUEST(xvQueryBestSizeReq); REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -959,11 +907,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
REQUEST(xvQueryPortAttributesReq); REQUEST(xvQueryPortAttributesReq);
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -1019,12 +963,7 @@ ProcXvPutImage(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xvPutImageReq); REQUEST_AT_LEAST_SIZE(xvPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -1105,12 +1044,7 @@ ProcXvShmPutImage(ClientPtr client)
REQUEST_SIZE_MATCH(xvShmPutImageReq); REQUEST_SIZE_MATCH(xvShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
if ((status = _AllocatePort(stuff->port, pPort)) != Success) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{ {
@ -1141,11 +1075,10 @@ ProcXvShmPutImage(ClientPtr client)
if(!pImage) if(!pImage)
return BadMatch; return BadMatch;
if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType))) status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg,
{ ShmSegType, serverClient, DixReadAccess);
client->errorValue = stuff->shmseg; if (status != Success)
return BadShmSegCode; return (status == BadValue) ? BadShmSegCode : status;
}
width = stuff->width; width = stuff->width;
height = stuff->height; height = stuff->height;
@ -1206,11 +1139,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
for(i = 0; i < pPort->pAdaptor->nImages; i++) { for(i = 0; i < pPort->pAdaptor->nImages; i++) {
if(pPort->pAdaptor->pImages[i].id == stuff->id) { if(pPort->pAdaptor->pImages[i].id == stuff->id) {
@ -1269,11 +1198,7 @@ ProcXvListImageFormats(ClientPtr client)
REQUEST_SIZE_MATCH(xvListImageFormatsReq); REQUEST_SIZE_MATCH(xvListImageFormatsReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client) )) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
{
client->errorValue = stuff->port;
return (_XvBadPort);
}
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
@ -1679,18 +1604,20 @@ SProcXvDispatch(ClientPtr client)
static int static int
XineramaXvStopVideo(ClientPtr client) XineramaXvStopVideo(ClientPtr client)
{ {
int result = Success, i; int result, i;
PanoramiXRes *draw, *port; PanoramiXRes *draw, *port;
REQUEST(xvStopVideoReq); REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) { if(port->info[i].id) {
@ -1708,13 +1635,14 @@ XineramaXvSetPortAttribute(ClientPtr client)
{ {
REQUEST(xvSetPortAttributeReq); REQUEST(xvSetPortAttributeReq);
PanoramiXRes *port; PanoramiXRes *port;
int result = Success, i; int result, i;
REQUEST_SIZE_MATCH(xvSetPortAttributeReq); REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS_BACKWARD(i) {
if(port->info[i].id) { if(port->info[i].id) {
@ -1733,21 +1661,24 @@ XineramaXvShmPutImage(ClientPtr client)
PanoramiXRes *draw, *gc, *port; PanoramiXRes *draw, *gc, *port;
Bool send_event = stuff->send_event; Bool send_event = stuff->send_event;
Bool isRoot; Bool isRoot;
int result = Success, i, x, y; int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq); REQUEST_SIZE_MATCH(xvShmPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
client, stuff->gc, XRT_GC, DixReadAccess))) XRT_GC, client, DixReadAccess);
return BadGC; if (result != Success)
return (result == BadValue) ? BadGC : result;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@ -1782,21 +1713,24 @@ XineramaXvPutImage(ClientPtr client)
REQUEST(xvPutImageReq); REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port; PanoramiXRes *draw, *gc, *port;
Bool isRoot; Bool isRoot;
int result = Success, i, x, y; int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq); REQUEST_AT_LEAST_SIZE(xvPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
client, stuff->gc, XRT_GC, DixReadAccess))) XRT_GC, client, DixReadAccess);
return BadGC; if (result != Success)
return (result == BadValue) ? BadGC : result;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@ -1827,21 +1761,24 @@ XineramaXvPutVideo(ClientPtr client)
REQUEST(xvPutImageReq); REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port; PanoramiXRes *draw, *gc, *port;
Bool isRoot; Bool isRoot;
int result = Success, i, x, y; int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutVideoReq); REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
client, stuff->gc, XRT_GC, DixReadAccess))) XRT_GC, client, DixReadAccess);
return BadGC; if (result != Success)
return (result == BadValue) ? BadGC : result;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
@ -1872,21 +1809,24 @@ XineramaXvPutStill(ClientPtr client)
REQUEST(xvPutImageReq); REQUEST(xvPutImageReq);
PanoramiXRes *draw, *gc, *port; PanoramiXRes *draw, *gc, *port;
Bool isRoot; Bool isRoot;
int result = Success, i, x, y; int result, i, x, y;
REQUEST_AT_LEAST_SIZE(xvPutImageReq); REQUEST_AT_LEAST_SIZE(xvPutImageReq);
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
client, stuff->gc, XRT_GC, DixReadAccess))) XRT_GC, client, DixReadAccess);
return BadGC; if (result != Success)
return (result == BadValue) ? BadGC : result;
if(!(port = (PanoramiXRes *)SecurityLookupIDByType( result = dixLookupResourceByType((pointer *)&port, stuff->port,
client, stuff->port, XvXRTPort, DixReadAccess))) XvXRTPort, client, DixReadAccess);
return _XvBadPort; if (result != Success)
return (result == BadValue) ? _XvBadPort : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;

View File

@ -201,17 +201,13 @@ typedef struct _XvPortRec {
DevUnion devPriv; DevUnion devPriv;
} XvPortRec, *XvPortPtr; } XvPortRec, *XvPortPtr;
#define LOOKUP_PORT(_id, client)\ #define VALIDATE_XV_PORT(portID, pPort, mode)\
((XvPortPtr)LookupIDByType(_id, XvRTPort)) {\
int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
#define LOOKUP_ENCODING(_id, client)\ XvRTPort, client, mode);\
((XvEncodingPtr)LookupIDByType(_id, XvRTEncoding)) if (rc != Success)\
return (rc == BadValue) ? _XvBadPort : rc;\
#define LOOKUP_VIDEONOTIFY_LIST(_id, client)\ }
((XvVideoNotifyPtr)LookupIDByType(_id, XvRTVideoNotifyList))
#define LOOKUP_PORTNOTIFY_LIST(_id, client)\
((XvPortNotifyPtr)LookupIDByType(_id, XvRTPortNotifyList))
typedef struct { typedef struct {
int version, revision; int version, revision;

View File

@ -523,7 +523,8 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
xvEvent event; xvEvent event;
XvVideoNotifyPtr pn; XvVideoNotifyPtr pn;
pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList); dixLookupResourceByType((pointer *)&pn, pDraw->id, XvRTVideoNotifyList,
serverClient, DixReadAccess);
while (pn) while (pn)
{ {
@ -905,10 +906,14 @@ XvdiSelectVideoNotify(
BOOL onoff BOOL onoff
){ ){
XvVideoNotifyPtr pn,tpn,fpn; XvVideoNotifyPtr pn,tpn,fpn;
int rc;
/* FIND VideoNotify LIST */ /* 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 */ /* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */

View File

@ -136,10 +136,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
REQUEST(xvmcListSurfaceTypesReq); REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq); REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client))) { VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
client->errorValue = stuff->port;
return _XvBadPort;
}
if(XvMCScreenKey) { /* any adaptors at all */ if(XvMCScreenKey) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen; ScreenPtr pScreen = pPort->pAdaptor->pScreen;
@ -192,10 +189,7 @@ ProcXvMCCreateContext(ClientPtr client)
REQUEST(xvmcCreateContextReq); REQUEST(xvmcCreateContextReq);
REQUEST_SIZE_MATCH(xvmcCreateContextReq); REQUEST_SIZE_MATCH(xvmcCreateContextReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client))) { VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
client->errorValue = stuff->port;
return _XvBadPort;
}
pScreen = pPort->pAdaptor->pScreen; pScreen = pPort->pAdaptor->pScreen;
@ -273,11 +267,15 @@ ProcXvMCCreateContext(ClientPtr client)
static int static int
ProcXvMCDestroyContext(ClientPtr client) ProcXvMCDestroyContext(ClientPtr client)
{ {
pointer val;
int rc;
REQUEST(xvmcDestroyContextReq); REQUEST(xvmcDestroyContextReq);
REQUEST_SIZE_MATCH(xvmcDestroyContextReq); REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
if(!LookupIDByType(stuff->context_id, XvMCRTContext)) rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
return (XvMCBadContext + XvMCErrorBase); client, DixDestroyAccess);
if (rc != Success)
return (rc == BadValue) ? XvMCBadContext + XvMCErrorBase : rc;
FreeResource(stuff->context_id, RT_NONE); FreeResource(stuff->context_id, RT_NONE);
@ -297,8 +295,10 @@ ProcXvMCCreateSurface(ClientPtr client)
REQUEST(xvmcCreateSurfaceReq); REQUEST(xvmcCreateSurfaceReq);
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq); REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext))) result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
return (XvMCBadContext + XvMCErrorBase); XvMCRTContext, client, DixUseAccess);
if (result != Success)
return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
@ -337,11 +337,15 @@ ProcXvMCCreateSurface(ClientPtr client)
static int static int
ProcXvMCDestroySurface(ClientPtr client) ProcXvMCDestroySurface(ClientPtr client)
{ {
pointer val;
int rc;
REQUEST(xvmcDestroySurfaceReq); REQUEST(xvmcDestroySurfaceReq);
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq); REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
if(!LookupIDByType(stuff->surface_id, XvMCRTSurface)) rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
return (XvMCBadSurface + XvMCErrorBase); client, DixDestroyAccess);
if (rc != Success)
return (rc == BadValue) ? XvMCBadSurface + XvMCErrorBase : rc;
FreeResource(stuff->surface_id, RT_NONE); FreeResource(stuff->surface_id, RT_NONE);
@ -363,8 +367,10 @@ ProcXvMCCreateSubpicture(ClientPtr client)
REQUEST(xvmcCreateSubpictureReq); REQUEST(xvmcCreateSubpictureReq);
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq); REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext))) result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
return (XvMCBadContext + XvMCErrorBase); XvMCRTContext, client, DixUseAccess);
if (result != Success)
return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
@ -448,11 +454,15 @@ ProcXvMCCreateSubpicture(ClientPtr client)
static int static int
ProcXvMCDestroySubpicture(ClientPtr client) ProcXvMCDestroySubpicture(ClientPtr client)
{ {
pointer val;
int rc;
REQUEST(xvmcDestroySubpictureReq); REQUEST(xvmcDestroySubpictureReq);
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq); REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
if(!LookupIDByType(stuff->subpicture_id, XvMCRTSubpicture)) rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
return (XvMCBadSubpicture + XvMCErrorBase); client, DixDestroyAccess);
if (rc != Success)
return (rc == BadValue) ? XvMCBadSubpicture + XvMCErrorBase : rc;
FreeResource(stuff->subpicture_id, RT_NONE); FreeResource(stuff->subpicture_id, RT_NONE);
@ -475,10 +485,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
REQUEST(xvmcListSubpictureTypesReq); REQUEST(xvmcListSubpictureTypesReq);
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq); REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
if(!(pPort = LOOKUP_PORT(stuff->port, client))) { VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
client->errorValue = stuff->port;
return _XvBadPort;
}
pScreen = pPort->pAdaptor->pScreen; pScreen = pPort->pAdaptor->pScreen;
@ -571,11 +578,7 @@ ProcXvMCGetDRInfo(ClientPtr client)
REQUEST(xvmcGetDRInfoReq); REQUEST(xvmcGetDRInfoReq);
REQUEST_SIZE_MATCH(xvmcGetDRInfoReq); REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
client->errorValue = stuff->port;
return _XvBadPort;
}
pScreen = pPort->pAdaptor->pScreen; pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen); pScreenPriv = XVMC_GET_PRIVATE(pScreen);

View File

@ -94,12 +94,10 @@ int ProcXChangeDeviceCursor(ClientPtr client)
} }
else else
{ {
pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor,
RT_CURSOR, DixReadAccess); RT_CURSOR, client, DixReadAccess);
if (!pCursor) if (rc != Success)
{ return (rc == BadValue) ? BadCursor : rc;
return BadCursor;
}
} }
ChangeWindowDeviceCursor(pWin, pDev, pCursor); ChangeWindowDeviceCursor(pWin, pDev, pCursor);

View File

@ -88,7 +88,7 @@ ProcXExtendedGrabDevice(ClientPtr client)
{ {
xExtendedGrabDeviceReply rep; xExtendedGrabDeviceReply rep;
DeviceIntPtr dev; DeviceIntPtr dev;
int rc = Success, int rc,
errval = 0, errval = 0,
i; i;
WindowPtr grab_window, WindowPtr grab_window,
@ -145,14 +145,12 @@ ProcXExtendedGrabDevice(ClientPtr client)
if (stuff->cursor) if (stuff->cursor)
{ {
cursor = (CursorPtr)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor,
stuff->cursor, RT_CURSOR, client, DixReadAccess);
RT_CURSOR, if (rc != Success)
DixReadAccess);
if (!cursor)
{ {
errval = stuff->cursor; errval = stuff->cursor;
rc = BadCursor; rc = (rc == BadValue) ? BadCursor : rc;
goto cleanup; goto cleanup;
} }
} }

View File

@ -58,11 +58,10 @@ typedef struct _DamageExt {
} DamageExtRec, *DamageExtPtr; } DamageExtRec, *DamageExtPtr;
#define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \ #define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \ int rc = dixLookupResourceByType((pointer *)&(pDamageExt), rid, \
if (!pDamageExt) { \ DamageExtType, client, mode); \
client->errorValue = rid; \ if (rc != Success) \
return DamageErrorBase + BadDamage; \ return (rc == BadValue) ? DamageErrorBase + BadDamage : rc; \
} \
} }
void void

View File

@ -411,20 +411,23 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
{ {
REQUEST(xDbeDeallocateBackBufferNameReq); REQUEST(xDbeDeallocateBackBufferNameReq);
DbeWindowPrivPtr pDbeWindowPriv; DbeWindowPrivPtr pDbeWindowPriv;
int i; int rc, i;
pointer val;
REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq); REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
/* Buffer name must be valid */ /* Buffer name must be valid */
if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
stuff->buffer, dbeWindowPrivResType, DixDestroyAccess)) || dbeWindowPrivResType, client,
!(SecurityLookupIDByType(client, stuff->buffer, dbeDrawableResType, DixDestroyAccess);
DixDestroyAccess))) if (rc != Success)
{ return (rc == BadValue) ? dbeErrorBase + DbeBadBuffer : rc;
client->errorValue = stuff->buffer;
return(dbeErrorBase + DbeBadBuffer); 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. /* Make sure that the id is valid for the window.
* This is paranoid code since we already looked up the ID by type * This is paranoid code since we already looked up the ID by type
@ -833,19 +836,21 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
REQUEST(xDbeGetBackBufferAttributesReq); REQUEST(xDbeGetBackBufferAttributesReq);
xDbeGetBackBufferAttributesReply rep; xDbeGetBackBufferAttributesReply rep;
DbeWindowPrivPtr pDbeWindowPriv; DbeWindowPrivPtr pDbeWindowPriv;
int n; int rc, n;
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pDbeWindowPriv, stuff->buffer,
stuff->buffer, dbeWindowPrivResType, DixGetAttrAccess))) dbeWindowPrivResType, client,
DixGetAttrAccess);
if (rc == Success)
{ {
rep.attributes = None; rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
} }
else else
{ {
rep.attributes = pDbeWindowPriv->pWindow->drawable.id; rep.attributes = None;
} }
rep.type = X_Reply; rep.type = X_Reply;

View File

@ -893,9 +893,9 @@ AllocColor (ColormapPtr pmap,
if (pmap->mid != pmap->pScreen->defColormap && if (pmap->mid != pmap->pScreen->defColormap &&
pmap->pVisual->vid == pmap->pScreen->rootVisual) pmap->pVisual->vid == pmap->pScreen->rootVisual)
{ {
ColormapPtr prootmap = (ColormapPtr) ColormapPtr prootmap;
SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
RT_COLORMAP, DixReadAccess); RT_COLORMAP, clients[client], DixReadAccess);
if (pmap->class == prootmap->class) if (pmap->class == prootmap->class)
FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
@ -910,9 +910,9 @@ AllocColor (ColormapPtr pmap,
if (pmap->mid != pmap->pScreen->defColormap && if (pmap->mid != pmap->pScreen->defColormap &&
pmap->pVisual->vid == pmap->pScreen->rootVisual) pmap->pVisual->vid == pmap->pScreen->rootVisual)
{ {
ColormapPtr prootmap = (ColormapPtr) ColormapPtr prootmap;
SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
RT_COLORMAP, DixReadAccess); RT_COLORMAP, clients[client], DixReadAccess);
if (pmap->class == prootmap->class) if (pmap->class == prootmap->class)
{ {
@ -1550,12 +1550,14 @@ FreePixels(ColormapPtr pmap, int client)
int int
FreeClientPixels (pointer value, XID fakeid) FreeClientPixels (pointer value, XID fakeid)
{ {
ColormapPtr pmap; pointer pmap;
colorResource *pcr = (colorResource *)value; colorResource *pcr = value;
int rc;
pmap = (ColormapPtr) LookupIDByType(pcr->mid, RT_COLORMAP); rc = dixLookupResourceByType(&pmap, pcr->mid, RT_COLORMAP, serverClient,
if (pmap) DixRemoveAccess);
FreePixels(pmap, pcr->client); if (rc == Success)
FreePixels((ColormapPtr)pmap, pcr->client);
xfree(pcr); xfree(pcr);
return Success; return Success;
} }

View File

@ -545,8 +545,9 @@ CreateRootCursor(char *unused1, unsigned int unused2)
if (err != Success) if (err != Success)
return NullCursor; return NullCursor;
cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT); err = dixLookupResourceByType((pointer *)&cursorfont, fontID, RT_FONT,
if (!cursorfont) serverClient, DixReadAccess);
if (err != Success)
return NullCursor; return NullCursor;
if (AllocGlyphCursor(fontID, 0, fontID, 1, 0, 0, 0, ~0, ~0, ~0, if (AllocGlyphCursor(fontID, 0, fontID, 1, 0, 0, 0, ~0, ~0, ~0,
&curs, serverClient, (XID)0) != Success) &curs, serverClient, (XID)0) != Success)

View File

@ -148,14 +148,18 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
pointer pointer
LookupIDByType(XID id, RESTYPE rtype) LookupIDByType(XID id, RESTYPE rtype)
{ {
return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess); pointer val;
dixLookupResourceByType(&val, id, rtype, NullClient, DixUnknownAccess);
return val;
} }
/* replaced by dixLookupResourceByClass */ /* replaced by dixLookupResourceByClass */
pointer pointer
LookupIDByClass(XID id, RESTYPE classes) 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} */ /* replaced by dixLookupResourceBy{Type,Class} */

View File

@ -1252,12 +1252,13 @@ int
ProcCloseFont(ClientPtr client) ProcCloseFont(ClientPtr client)
{ {
FontPtr pFont; FontPtr pFont;
int rc;
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT,
DixDestroyAccess); client, DixDestroyAccess);
if ( pFont != (FontPtr)NULL) /* id was valid */ if (rc == Success)
{ {
FreeResource(stuff->id, RT_NONE); FreeResource(stuff->id, RT_NONE);
return(client->noClientException); return(client->noClientException);
@ -1265,7 +1266,7 @@ ProcCloseFont(ClientPtr client)
else else
{ {
client->errorValue = stuff->id; client->errorValue = stuff->id;
return (BadFont); return (rc == BadValue) ? BadFont : rc;
} }
} }

View File

@ -137,8 +137,9 @@ SetDefaultFont(char *defaultfontname)
(unsigned) strlen(defaultfontname), defaultfontname); (unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success) if (err != Success)
return FALSE; return FALSE;
pf = (FontPtr) LookupIDByType(fid, RT_FONT); err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
if (pf == (FontPtr) NULL) DixReadAccess);
if (err != Success)
return FALSE; return FALSE;
defaultFont = pf; defaultFont = pf;
return TRUE; return TRUE;
@ -1201,11 +1202,11 @@ doPolyText(ClientPtr client, PTclosurePtr c)
} }
/* Make sure our drawable hasn't disappeared while we slept. */ /* Make sure our drawable hasn't disappeared while we slept. */
if (c->slept && if (c->slept && c->pDraw)
c->pDraw &&
c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
RC_DRAWABLE, DixWriteAccess))
{ {
DrawablePtr pDraw;
dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
if (c->pDraw != pDraw) {
/* Our drawable has disappeared. Treat like client died... ask /* Our drawable has disappeared. Treat like client died... ask
the FPE code to clean up after client and avoid further the FPE code to clean up after client and avoid further
rendering while we clean up after ourself. */ rendering while we clean up after ourself. */
@ -1213,6 +1214,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
c->pDraw = (DrawablePtr)0; c->pDraw = (DrawablePtr)0;
} }
}
client_state = c->slept ? SLEEPING : NEVER_SLEPT; client_state = c->slept ? SLEEPING : NEVER_SLEPT;
@ -1233,12 +1235,11 @@ doPolyText(ClientPtr client, PTclosurePtr c)
| ((Font)*(c->pElt+3)) << 8 | ((Font)*(c->pElt+3)) << 8
| ((Font)*(c->pElt+2)) << 16 | ((Font)*(c->pElt+2)) << 16
| ((Font)*(c->pElt+1)) << 24; | ((Font)*(c->pElt+1)) << 24;
pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
DixReadAccess); client, DixReadAccess);
if (!pFont) if (err != Success)
{ {
client->errorValue = fid; err = (err == BadValue) ? BadFont : err;
err = BadFont;
/* restore pFont and fid for step 4 (described below) */ /* restore pFont and fid for step 4 (described below) */
pFont = oldpFont; pFont = oldpFont;
fid = oldfid; fid = oldfid;
@ -1486,11 +1487,11 @@ doImageText(ClientPtr client, ITclosurePtr c)
} }
/* Make sure our drawable hasn't disappeared while we slept. */ /* Make sure our drawable hasn't disappeared while we slept. */
if (c->slept && if (c->slept && c->pDraw)
c->pDraw &&
c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
RC_DRAWABLE, DixWriteAccess))
{ {
DrawablePtr pDraw;
dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
if (c->pDraw != pDraw) {
/* Our drawable has disappeared. Treat like client died... ask /* Our drawable has disappeared. Treat like client died... ask
the FPE code to clean up after client. */ the FPE code to clean up after client. */
fpe = c->pGC->font->fpe; fpe = c->pGC->font->fpe;
@ -1498,6 +1499,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
err = Success; err = Success;
goto bail; goto bail;
} }
}
lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data); lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
if (lgerr == Suspended) if (lgerr == Suspended)
@ -2013,8 +2015,9 @@ FreeFonts(void)
FontPtr FontPtr
find_old_font(XID id) find_old_font(XID id)
{ {
return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, pointer pFont;
DixUnknownAccess); dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
return (FontPtr)pFont;
} }
Font Font

View File

@ -240,14 +240,9 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
int int
dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access) dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
{ {
GCPtr pTmp = (GCPtr)SecurityLookupIDByType(client, id, RT_GC, access); int rc;
if (pTmp) { rc = dixLookupResourceByType((pointer *)pGC, id, RT_GC, client, access);
*pGC = pTmp; return (rc == BadValue) ? BadGC : rc;
return Success;
}
client->errorValue = id;
*pGC = NULL;
return BadGC;
} }
int int

View File

@ -506,16 +506,17 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
PanoramiXNumScreens*sizeof(WindowPtr)); PanoramiXNumScreens*sizeof(WindowPtr));
} else { } else {
PanoramiXRes *win; PanoramiXRes *win;
int i; int rc, i;
win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW); rc = dixLookupResourceByType((pointer *)&win, pWin->drawable.id,
XRT_WINDOW, serverClient, DixReadAccess);
if(!win) if (rc != Success)
return FALSE; return FALSE;
for(i = 0; i < PanoramiXNumScreens; i++) { for(i = 0; i < PanoramiXNumScreens; i++) {
pSprite->windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW); rc = dixLookupWindow(pSprite->windows + i, win->info[i].id,
if(!pSprite->windows[i]) /* window is being unmapped */ serverClient, DixReadAccess);
if (rc != Success) /* window is being unmapped */
return FALSE; return FALSE;
} }
} }

View File

@ -392,13 +392,16 @@ unsigned int
GetXIDList(ClientPtr pClient, unsigned count, XID *pids) GetXIDList(ClientPtr pClient, unsigned count, XID *pids)
{ {
unsigned int found = 0; unsigned int found = 0;
XID id = pClient->clientAsMask; XID rc, id = pClient->clientAsMask;
XID maxid; XID maxid;
pointer val;
maxid = id | RESOURCE_ID_MASK; maxid = id | RESOURCE_ID_MASK;
while ( (found < count) && (id <= maxid) ) while ( (found < count) && (id <= maxid) )
{ {
if (!LookupIDByClass(id, RC_ANY)) rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient,
DixGetAttrAccess);
if (rc == BadValue)
{ {
pids[found++] = id; pids[found++] = id;
} }
@ -826,6 +829,8 @@ FreeAllResources(void)
Bool Bool
LegalNewID(XID id, ClientPtr client) LegalNewID(XID id, ClientPtr client)
{ {
pointer val;
int rc;
#ifdef PANORAMIX #ifdef PANORAMIX
XID minid, maxid; XID minid, maxid;
@ -838,9 +843,16 @@ LegalNewID(XID id, ClientPtr client)
return TRUE; return TRUE;
} }
#endif /* PANORAMIX */ #endif /* PANORAMIX */
return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) && if (client->clientAsMask == (id & ~RESOURCE_ID_MASK))
((clientTable[client->index].expectID <= id) || {
!LookupIDByClass(id, RC_ANY))); if (clientTable[client->index].expectID <= id)
return TRUE;
rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient,
DixGetAttrAccess);
return (rc == BadValue);
}
return FALSE;
} }
int int

View File

@ -2795,6 +2795,7 @@ UnrealizeTree(
WindowPtr pChild; WindowPtr pChild;
UnrealizeWindowProcPtr Unrealize; UnrealizeWindowProcPtr Unrealize;
MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
int rc;
Unrealize = pWin->drawable.pScreen->UnrealizeWindow; Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow; MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
@ -2808,9 +2809,10 @@ UnrealizeTree(
#ifdef PANORAMIX #ifdef PANORAMIX
if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) { if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) {
PanoramiXRes *win; PanoramiXRes *win;
win = (PanoramiXRes*)LookupIDByType(pChild->drawable.id, rc = dixLookupResourceByType((pointer *)&win,
XRT_WINDOW); pChild->drawable.id, XRT_WINDOW,
if(win) serverClient, DixWriteAccess);
if (rc == Success)
win->u.win.visibility = VisibilityNotViewable; win->u.win.visibility = VisibilityNotViewable;
} }
#endif #endif
@ -3072,7 +3074,7 @@ SendVisibilityNotify(WindowPtr pWin)
if(!noPanoramiXExtension) { if(!noPanoramiXExtension) {
PanoramiXRes *win; PanoramiXRes *win;
WindowPtr pWin2; WindowPtr pWin2;
int i, Scrnum; int rc, i, Scrnum;
Scrnum = pWin->drawable.pScreen->myNum; Scrnum = pWin->drawable.pScreen->myNum;
@ -3086,9 +3088,10 @@ SendVisibilityNotify(WindowPtr pWin)
for(i = 0; i < PanoramiXNumScreens; i++) { for(i = 0; i < PanoramiXNumScreens; i++) {
if(i == Scrnum) continue; 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) if(pWin2->visibility == VisibilityPartiallyObscured)
return; return;
@ -3098,17 +3101,19 @@ SendVisibilityNotify(WindowPtr pWin)
break; break;
case VisibilityPartiallyObscured: case VisibilityPartiallyObscured:
if(Scrnum) { if(Scrnum) {
pWin2 = (WindowPtr)LookupIDByType(win->info[0].id, RT_WINDOW); rc = dixLookupWindow(&pWin2, win->info[0].id, serverClient,
if (pWin2) pWin = pWin2; DixWriteAccess);
if (rc == Success) pWin = pWin2;
} }
break; break;
case VisibilityFullyObscured: case VisibilityFullyObscured:
for(i = 0; i < PanoramiXNumScreens; i++) { for(i = 0; i < PanoramiXNumScreens; i++) {
if(i == Scrnum) continue; 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) if(pWin2->visibility != VisibilityFullyObscured)
return; return;
@ -3739,7 +3744,7 @@ DrawLogo(WindowPtr pWin)
int x, y; int x, y;
unsigned int width, height, size; unsigned int width, height, size;
GC *pGC; GC *pGC;
int thin, gap, d31; int rc, thin, gap, d31;
DDXPointRec poly[4]; DDXPointRec poly[4];
ChangeGCVal fore[2], back[2]; ChangeGCVal fore[2], back[2];
xrgb rgb[2]; xrgb rgb[2];
@ -3760,8 +3765,10 @@ DrawLogo(WindowPtr pWin)
fore[0].val = pScreen->whitePixel; fore[0].val = pScreen->whitePixel;
else else
fore[0].val = pScreen->blackPixel; fore[0].val = pScreen->blackPixel;
if ((pWin->backgroundState == BackgroundPixel) && if (pWin->backgroundState == BackgroundPixel) {
(cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) { rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
RT_COLORMAP, serverClient, DixReadAccess);
if (rc == Success) {
Pixel querypixels[2]; Pixel querypixels[2];
querypixels[0] = fore[0].val; querypixels[0] = fore[0].val;
@ -3776,6 +3783,7 @@ DrawLogo(WindowPtr pWin)
fore[0].val = pScreen->blackPixel; fore[0].val = pScreen->blackPixel;
} }
} }
}
fore[1].val = FillSolid; fore[1].val = FillSolid;
fmask = GCForeground|GCFillStyle; fmask = GCForeground|GCFillStyle;
if (pWin->backgroundState == BackgroundPixel) { if (pWin->backgroundState == BackgroundPixel) {

View File

@ -85,8 +85,10 @@ fbUninstallColormap(ColormapPtr pmap)
{ {
if (pmap->mid != pmap->pScreen->defColormap) if (pmap->mid != pmap->pScreen->defColormap)
{ {
curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&curpmap,
RT_COLORMAP); pmap->pScreen->defColormap,
RT_COLORMAP,
serverClient, DixInstallAccess);
(*pmap->pScreen->InstallColormap)(curpmap); (*pmap->pScreen->InstallColormap)(curpmap);
} }
} }

View File

@ -217,7 +217,8 @@ KdUninstallColormap (ColormapPtr pCmap)
return; return;
/* install default if on same fb */ /* 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) if (defMap && KdColormapFb (defMap) == fb)
(*pCmap->pScreen->InstallColormap)(defMap); (*pCmap->pScreen->InstallColormap)(defMap);
else else

View File

@ -508,8 +508,10 @@ vfbUninstallColormap(ColormapPtr pmap)
{ {
if (pmap->mid != pmap->pScreen->defColormap) if (pmap->mid != pmap->pScreen->defColormap)
{ {
curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&curpmap,
RT_COLORMAP); pmap->pScreen->defColormap,
RT_COLORMAP, serverClient,
DixInstallAccess);
(*pmap->pScreen->InstallColormap)(curpmap); (*pmap->pScreen->InstallColormap)(curpmap);
} }
} }

View File

@ -211,8 +211,8 @@ Bool xf86HandleColormaps(
ComputeGamma(pScreenPriv); ComputeGamma(pScreenPriv);
/* get the default map */ /* get the default map */
dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); RT_COLORMAP, serverClient, DixInstallAccess);
if(!CMapAllocateColormapPrivate(pDefMap)) { if(!CMapAllocateColormapPrivate(pDefMap)) {
CMapUnwrapScreen(pScreen); CMapUnwrapScreen(pScreen);

View File

@ -420,6 +420,7 @@ static int
ProcXDGAInstallColormap(ClientPtr client) ProcXDGAInstallColormap(ClientPtr client)
{ {
ColormapPtr cmap; ColormapPtr cmap;
int rc;
REQUEST(xXDGAInstallColormapReq); REQUEST(xXDGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens) if (stuff->screen > screenInfo.numScreens)
@ -430,13 +431,13 @@ ProcXDGAInstallColormap(ClientPtr client)
REQUEST_SIZE_MATCH(xXDGAInstallColormapReq); REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP); rc = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, RT_COLORMAP,
if (cmap) { client, DixInstallAccess);
if (rc == Success) {
DGAInstallCmap(cmap); DGAInstallCmap(cmap);
return (client->noClientException); return (client->noClientException);
} else { } else {
client->errorValue = stuff->cmap; return (rc == BadValue) ? BadColor : rc;
return (BadColor);
} }
return (client->noClientException); return (client->noClientException);
@ -858,6 +859,7 @@ static int
ProcXF86DGAInstallColormap(ClientPtr client) ProcXF86DGAInstallColormap(ClientPtr client)
{ {
ColormapPtr pcmp; ColormapPtr pcmp;
int rc;
REQUEST(xXF86DGAInstallColormapReq); REQUEST(xXF86DGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens) if (stuff->screen > screenInfo.numScreens)
@ -871,13 +873,13 @@ ProcXF86DGAInstallColormap(ClientPtr client)
if (!DGAActive(stuff->screen)) if (!DGAActive(stuff->screen))
return (DGAErrorBase + XF86DGADirectNotActivated); return (DGAErrorBase + XF86DGADirectNotActivated);
pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP); rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
if (pcmp) { client, DixInstallAccess);
if (rc == Success) {
DGAInstallCmap(pcmp); DGAInstallCmap(pcmp);
return (client->noClientException); return (client->noClientException);
} else { } else {
client->errorValue = stuff->id; return (rc == BadValue) ? BadColor : rc;
return (BadColor);
} }
} }

View File

@ -1363,11 +1363,12 @@ Bool
DRIDrawablePrivDelete(pointer pResource, XID id) DRIDrawablePrivDelete(pointer pResource, XID id)
{ {
WindowPtr pWin; WindowPtr pWin;
int rc;
id = (XID)pResource; 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); DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
if (!pDRIDrwPriv) if (!pDRIDrwPriv)

View File

@ -277,8 +277,8 @@ vgaUninstallColormap(pmap)
if ( pmap != miInstalledMaps[pmap->pScreen->myNum] ) if ( pmap != miInstalledMaps[pmap->pScreen->myNum] )
return; return;
defColormap = (ColormapPtr) LookupIDByType( pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&defColormap, pmap->pScreen->defColormap,
RT_COLORMAP); RT_COLORMAP, serverClient, DixInstallAccess);
if (defColormap == miInstalledMaps[pmap->pScreen->myNum]) if (defColormap == miInstalledMaps[pmap->pScreen->myNum])
return; return;

View File

@ -247,11 +247,11 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
visual = xnestVisualFromID(pScreen, wVisual(pWin)); visual = xnestVisualFromID(pScreen, wVisual(pWin));
if (visual == xnestDefaultVisual(pScreen)) if (visual == xnestDefaultVisual(pScreen))
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
RT_COLORMAP); RT_COLORMAP, serverClient, DixUseAccess);
else else
pCmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, dixLookupResourceByType((pointer *)&pCmap, pScreen->defColormap,
RT_COLORMAP); RT_COLORMAP, serverClient, DixUseAccess);
XSetWindowColormap(xnestDisplay, XSetWindowColormap(xnestDisplay,
xnestDefaultWindows[pScreen->myNum], xnestDefaultWindows[pScreen->myNum],
@ -302,7 +302,8 @@ xnestDirectInstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
ColormapPtr pCmap; ColormapPtr pCmap;
pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP,
serverClient, DixInstallAccess);
if (pCmap) if (pCmap)
XInstallColormap(xnestDisplay, xnestColormap(pCmap)); XInstallColormap(xnestDisplay, xnestColormap(pCmap));
} }
@ -321,7 +322,8 @@ xnestDirectUninstallColormaps(ScreenPtr pScreen)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
ColormapPtr pCmap; ColormapPtr pCmap;
pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP,
serverClient, DixUninstallAccess);
if (pCmap) if (pCmap)
XUninstallColormap(xnestDisplay, xnestColormap(pCmap)); XUninstallColormap(xnestDisplay, xnestColormap(pCmap));
} }
@ -365,8 +367,10 @@ xnestUninstallColormap(ColormapPtr pCmap)
{ {
if (pCmap->mid != pCmap->pScreen->defColormap) if (pCmap->mid != pCmap->pScreen->defColormap)
{ {
pCurCmap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&pCurCmap,
RT_COLORMAP); pCmap->pScreen->defColormap,
RT_COLORMAP,
serverClient, DixInstallAccess);
(*pCmap->pScreen->InstallColormap)(pCurCmap); (*pCmap->pScreen->InstallColormap)(pCurCmap);
} }
} }

View File

@ -93,7 +93,8 @@ xnestCreateWindow(WindowPtr pWin)
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
mask |= CWColormap; mask |= CWColormap;
if (pWin->optional->colormap) { if (pWin->optional->colormap) {
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP); dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
RT_COLORMAP, serverClient, DixUseAccess);
attributes.colormap = xnestColormap(pCmap); attributes.colormap = xnestColormap(pCmap);
} }
else else
@ -104,7 +105,8 @@ xnestCreateWindow(WindowPtr pWin)
} }
else { /* root windows have their own colormaps at creation time */ else { /* root windows have their own colormaps at creation time */
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); 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; mask |= CWColormap;
attributes.colormap = xnestColormap(pCmap); attributes.colormap = xnestColormap(pCmap);
} }
@ -338,7 +340,8 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (mask & CWColormap) { if (mask & CWColormap) {
ColormapPtr pCmap; ColormapPtr pCmap;
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP); dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), RT_COLORMAP,
serverClient, DixUseAccess);
attributes.colormap = xnestColormap(pCmap); attributes.colormap = xnestColormap(pCmap);

View File

@ -87,8 +87,10 @@ miUninstallColormap(ColormapPtr pmap)
{ {
if (pmap->mid != pmap->pScreen->defColormap) if (pmap->mid != pmap->pScreen->defColormap)
{ {
curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap, dixLookupResourceByType((pointer *)&curpmap,
RT_COLORMAP); pmap->pScreen->defColormap,
RT_COLORMAP, serverClient,
DixUseAccess);
(*pmap->pScreen->InstallColormap)(curpmap); (*pmap->pScreen->InstallColormap)(curpmap);
} }
} }

View File

@ -436,7 +436,7 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
return; return;
} }
realWin = win->info[0].id; realWin = win->info[0].id;
pWin = LookupIDByType(realWin, RT_WINDOW); dixLookupWindow(&pWin, realWin, serverClient, DixSendAccess);
} }
if(x || y || scrnum) if(x || y || scrnum)
for (i = 0; i < numRects; i++) { for (i = 0; i < numRects; i++) {

View File

@ -279,7 +279,8 @@ RRFreeClient (pointer data, XID id)
pRREvent = (RREventPtr) data; pRREvent = (RREventPtr) data;
pWin = pRREvent->window; pWin = pRREvent->window;
pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, RREventType); dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
RREventType, serverClient, DixDestroyAccess);
if (pHead) { if (pHead) {
pPrev = 0; pPrev = 0;
for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next) for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next)
@ -357,7 +358,8 @@ TellChanged (WindowPtr pWin, pointer value)
rrScrPriv(pScreen); rrScrPriv(pScreen);
int i; int i;
pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, RREventType); dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
RREventType, serverClient, DixReadAccess);
if (!pHead) if (!pHead)
return WT_WALKCHILDREN; return WT_WALKCHILDREN;

View File

@ -340,15 +340,29 @@ extern _X_EXPORT RESTYPE RRClientType, RREventType; /* resource types for event
extern _X_EXPORT DevPrivateKey RRClientPrivateKey; extern _X_EXPORT DevPrivateKey RRClientPrivateKey;
extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType; extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
#define LookupOutput(client,id,a) ((RROutputPtr) \ #define VERIFY_RR_OUTPUT(id, ptr, a)\
(SecurityLookupIDByType (client, id, \ {\
RROutputType, a))) int rc = dixLookupResourceByType((pointer *)&(ptr), id,\
#define LookupCrtc(client,id,a) ((RRCrtcPtr) \ RROutputType, client, a);\
(SecurityLookupIDByType (client, id, \ if (rc != Success)\
RRCrtcType, a))) return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;\
#define LookupMode(client,id,a) ((RRModePtr) \ }
(SecurityLookupIDByType (client, id, \
RRModeType, a))) #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 GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient) #define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)

View File

@ -658,10 +658,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
BoxRec panned_area; BoxRec panned_area;
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
crtc = LookupCrtc(client, stuff->crtc, DixReadAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
/* All crtcs must be associated with screens before client /* All crtcs must be associated with screens before client
* requests are processed * requests are processed
@ -775,17 +772,13 @@ ProcRRSetCrtcConfig (ClientPtr client)
TimeStamp configTime; TimeStamp configTime;
TimeStamp time; TimeStamp time;
Rotation rotation; Rotation rotation;
int i, j; int rc, i, j;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2)); numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
crtc = LookupIDByType (stuff->crtc, RRCrtcType); VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);
if (!crtc)
{
client->errorValue = stuff->crtc;
return RRErrorBase + BadRRCrtc;
}
if (stuff->mode == None) if (stuff->mode == None)
{ {
mode = NULL; mode = NULL;
@ -794,12 +787,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
} }
else else
{ {
mode = LookupIDByType (stuff->mode, RRModeType); VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess);
if (!mode)
{
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
if (numOutputs == 0) if (numOutputs == 0)
return BadMatch; return BadMatch;
} }
@ -815,13 +803,13 @@ ProcRRSetCrtcConfig (ClientPtr client)
outputIds = (RROutput *) (stuff + 1); outputIds = (RROutput *) (stuff + 1);
for (i = 0; i < numOutputs; i++) for (i = 0; i < numOutputs; i++)
{ {
outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType); rc = dixLookupResourceByType((pointer *)(outputs + i), outputIds[i],
if (!outputs[i]) RROutputType, client, DixSetAttrAccess);
if (rc != Success)
{ {
client->errorValue = outputIds[i];
if (outputs) if (outputs)
xfree (outputs); xfree (outputs);
return RRErrorBase + BadRROutput; return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;
} }
/* validate crtc for this output */ /* validate crtc for this output */
for (j = 0; j < outputs[i]->numCrtcs; j++) for (j = 0; j < outputs[i]->numCrtcs; j++)
@ -1027,10 +1015,7 @@ ProcRRGetPanning (ClientPtr client)
int n; int n;
REQUEST_SIZE_MATCH(xRRGetPanningReq); REQUEST_SIZE_MATCH(xRRGetPanningReq);
crtc = LookupCrtc(client, stuff->crtc, DixReadAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
/* All crtcs must be associated with screens before client /* All crtcs must be associated with screens before client
* requests are processed * requests are processed
@ -1100,11 +1085,7 @@ ProcRRSetPanning (ClientPtr client)
int n; int n;
REQUEST_SIZE_MATCH(xRRSetPanningReq); REQUEST_SIZE_MATCH(xRRSetPanningReq);
crtc = LookupCrtc(client, stuff->crtc, DixReadAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
/* All crtcs must be associated with screens before client /* All crtcs must be associated with screens before client
* requests are processed * requests are processed
@ -1175,9 +1156,7 @@ ProcRRGetCrtcGammaSize (ClientPtr client)
int n; int n;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
crtc = LookupCrtc (client, stuff->crtc, DixReadAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
/* Gamma retrieval failed, any better error? */ /* Gamma retrieval failed, any better error? */
if (!RRCrtcGammaGet(crtc)) if (!RRCrtcGammaGet(crtc))
@ -1207,9 +1186,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
char *extra = NULL; char *extra = NULL;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
crtc = LookupCrtc (client, stuff->crtc, DixReadAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
/* Gamma retrieval failed, any better error? */ /* Gamma retrieval failed, any better error? */
if (!RRCrtcGammaGet(crtc)) if (!RRCrtcGammaGet(crtc))
@ -1252,9 +1229,7 @@ ProcRRSetCrtcGamma (ClientPtr client)
CARD16 *red, *green, *blue; CARD16 *red, *green, *blue;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2); len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2);
if (len < (stuff->size * 3 + 1) >> 1) if (len < (stuff->size * 3 + 1) >> 1)
@ -1287,9 +1262,7 @@ ProcRRSetCrtcTransform (ClientPtr client)
int nparams; int nparams;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
PictTransform_from_xRenderTransform (&transform, &stuff->transform); PictTransform_from_xRenderTransform (&transform, &stuff->transform);
pixman_f_transform_from_pixman_transform (&f_transform, &transform); pixman_f_transform_from_pixman_transform (&f_transform, &transform);
@ -1372,9 +1345,7 @@ ProcRRGetCrtcTransform (ClientPtr client)
char *extra; char *extra;
REQUEST_SIZE_MATCH (xRRGetCrtcTransformReq); REQUEST_SIZE_MATCH (xRRGetCrtcTransformReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
pending = &crtc->client_pending_transform; pending = &crtc->client_pending_transform;
current = &crtc->client_current_transform; current = &crtc->client_current_transform;

View File

@ -79,9 +79,10 @@ ProcRRSelectInput (ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
pHead = (RREventPtr *)SecurityLookupIDByType(client, rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
pWin->drawable.id, RREventType, RREventType, client, DixWriteAccess);
DixWriteAccess); if (rc != Success && rc != BadValue)
return rc;
if (stuff->enable & (RRScreenChangeNotifyMask| if (stuff->enable & (RRScreenChangeNotifyMask|
RRCrtcChangeNotifyMask| RRCrtcChangeNotifyMask|

View File

@ -332,12 +332,8 @@ ProcRRDestroyMode (ClientPtr client)
RRModePtr mode; RRModePtr mode;
REQUEST_SIZE_MATCH(xRRDestroyModeReq); REQUEST_SIZE_MATCH(xRRDestroyModeReq);
mode = LookupIDByType (stuff->mode, RRModeType); VERIFY_RR_MODE(stuff->mode, mode, DixDestroyAccess);
if (!mode)
{
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
if (!mode->userScreen) if (!mode->userScreen)
return BadMatch; return BadMatch;
if (mode->refcnt > 1) if (mode->refcnt > 1)
@ -354,20 +350,8 @@ ProcRRAddOutputMode (ClientPtr client)
RROutputPtr output; RROutputPtr output;
REQUEST_SIZE_MATCH(xRRAddOutputModeReq); REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
output = LookupOutput(client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
if (!output)
{
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
return RROutputAddUserMode (output, mode); return RROutputAddUserMode (output, mode);
} }
@ -380,20 +364,8 @@ ProcRRDeleteOutputMode (ClientPtr client)
RROutputPtr output; RROutputPtr output;
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
output = LookupOutput(client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
if (!output)
{
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
return RROutputDeleteUserMode (output, mode); return RROutputDeleteUserMode (output, mode);
} }

View File

@ -448,13 +448,7 @@ ProcRRGetOutputInfo (ClientPtr client)
int i, n; int i, n;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
output = LookupOutput(client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
{
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
pScreen = output->pScreen; pScreen = output->pScreen;
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
@ -569,24 +563,16 @@ ProcRRSetOutputPrimary(ClientPtr client)
RROutputPtr output = NULL; RROutputPtr output = NULL;
WindowPtr pWin; WindowPtr pWin;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
int rc;
REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW, rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
DixReadAccess); if (rc != Success)
return rc;
if (!pWin) {
client->errorValue = stuff->window;
return BadWindow;
}
if (stuff->output) { if (stuff->output) {
output = LookupOutput(client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output) {
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
if (output->pScreen != pWin->drawable.pScreen) { if (output->pScreen != pWin->drawable.pScreen) {
client->errorValue = stuff->window; client->errorValue = stuff->window;
@ -608,16 +594,13 @@ ProcRRGetOutputPrimary(ClientPtr client)
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
xRRGetOutputPrimaryReply rep; xRRGetOutputPrimaryReply rep;
RROutputPtr primary = NULL; RROutputPtr primary = NULL;
int rc;
REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW, rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
DixReadAccess); if (rc != Success)
return rc;
if (!pWin) {
client->errorValue = stuff->window;
return BadWindow;
}
pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
if (pScrPriv) if (pScrPriv)

View File

@ -31,7 +31,8 @@ DeliverPropertyEvent(WindowPtr pWin, void *value)
RREventPtr *pHead, pRREvent; RREventPtr *pHead, pRREvent;
ClientPtr client; ClientPtr client;
pHead = LookupIDByType(pWin->drawable.id, RREventType); dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
RREventType, serverClient, DixReadAccess);
if (!pHead) if (!pHead)
return WT_WALKCHILDREN; return WT_WALKCHILDREN;
@ -419,10 +420,7 @@ ProcRRListOutputProperties (ClientPtr client)
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
output = LookupOutput (client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
for (prop = output->properties; prop; prop = prop->next) for (prop = output->properties; prop; prop = prop->next)
numProps++; numProps++;
@ -466,10 +464,7 @@ ProcRRQueryOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
output = LookupOutput (client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
prop = RRQueryOutputProperty (output, stuff->property); prop = RRQueryOutputProperty (output, stuff->property);
if (!prop) if (!prop)
@ -513,10 +508,7 @@ ProcRRConfigureOutputProperty (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq); REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq);
output = LookupOutput (client, stuff->output, DixReadAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2); num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2);
return RRConfigureOutputProperty (output, stuff->property, return RRConfigureOutputProperty (output, stuff->property,
@ -558,9 +550,7 @@ ProcRRChangeOutputProperty (ClientPtr client)
totalSize = len * sizeInBytes; totalSize = len * sizeInBytes;
REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize); REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize);
output = LookupOutput (client, stuff->output, DixWriteAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property)) if (!ValidAtom(stuff->property))
{ {
@ -590,9 +580,7 @@ ProcRRDeleteOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
UpdateCurrentTime(); UpdateCurrentTime();
output = LookupOutput (client, stuff->output, DixWriteAccess); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property)) if (!ValidAtom(stuff->property))
{ {
@ -619,11 +607,8 @@ ProcRRGetOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
if (stuff->delete) if (stuff->delete)
UpdateCurrentTime(); UpdateCurrentTime();
output = LookupOutput (client, stuff->output, VERIFY_RR_OUTPUT(stuff->output, output,
stuff->delete ? DixWriteAccess : stuff->delete ? DixWriteAccess : DixReadAccess);
DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property)) if (!ValidAtom(stuff->property))
{ {

View File

@ -127,11 +127,10 @@ static int numEnabledRCAPs;
* returns an error. * returns an error.
*/ */
#define VERIFY_CONTEXT(_pContext, _contextid, _client) { \ #define VERIFY_CONTEXT(_pContext, _contextid, _client) { \
(_pContext) = (RecordContextPtr)LookupIDByType((_contextid), RTContext); \ int rc = dixLookupResourceByType((pointer *)&(_pContext), _contextid, \
if (!(_pContext)) { \ RTContext, _client, DixUseAccess); \
(_client)->errorValue = (_contextid); \ if (rc != Success) \
return RecordErrorBase + XRecordBadContext; \ return (rc == BadValue) ? RecordErrorBase + XRecordBadContext : rc; \
} \
} }
static int RecordDeleteContext( static int RecordDeleteContext(

View File

@ -410,8 +410,9 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
return TRUE; return TRUE;
if (format->index.vid == pScreen->rootVisual) { if (format->index.vid == pScreen->rootVisual) {
format->index.pColormap = dixLookupResourceByType((pointer *)&format->index.pColormap,
(ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); pScreen->defColormap, RT_COLORMAP,
serverClient, DixGetAttrAccess);
} else { } else {
VisualPtr pVisual = PictureFindVisual(pScreen, format->index.vid); VisualPtr pVisual = PictureFindVisual(pScreen, format->index.vid);
if (CreateColormap(FakeClientID (0), pScreen, pVisual, if (CreateColormap(FakeClientID (0), pScreen, pVisual,

View File

@ -409,11 +409,10 @@ extern _X_EXPORT RESTYPE GlyphSetType;
#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p) #define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\ #define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\ int rc = dixLookupResourceByType((pointer)&(pPicture), pid,\
if (!pPicture) { \ PictureType, client, mode);\
client->errorValue = pid; \ if (rc != Success)\
return err; \ return (rc == BadValue) ? err : rc;\
} \
} }
#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\ #define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\

View File

@ -509,7 +509,7 @@ static int
ProcRenderQueryPictIndexValues (ClientPtr client) ProcRenderQueryPictIndexValues (ClientPtr client)
{ {
PictFormatPtr pFormat; PictFormatPtr pFormat;
int num; int rc, num;
int rlength; int rlength;
int i, n; int i, n;
REQUEST(xRenderQueryPictIndexValuesReq); REQUEST(xRenderQueryPictIndexValuesReq);
@ -518,16 +518,11 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
stuff->format, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->format;
return RenderErrBase + BadPictFormat;
}
if (pFormat->type != PictTypeIndexed) if (pFormat->type != PictTypeIndexed)
{ {
client->errorValue = stuff->format; client->errorValue = stuff->format;
@ -592,15 +587,11 @@ ProcRenderCreatePicture (ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
stuff->format, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->format;
return RenderErrBase + BadPictFormat;
}
if (pFormat->depth != pDrawable->depth) if (pFormat->depth != pDrawable->depth)
return BadMatch; return BadMatch;
len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2); len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2);
@ -740,7 +731,7 @@ ProcRenderScale (ClientPtr client)
static int static int
ProcRenderTrapezoids (ClientPtr client) ProcRenderTrapezoids (ClientPtr client)
{ {
int ntraps; int rc, ntraps;
PicturePtr pSrc, pDst; PicturePtr pSrc, pDst;
PictFormatPtr pFormat; PictFormatPtr pFormat;
REQUEST(xRenderTrapezoidsReq); REQUEST(xRenderTrapezoidsReq);
@ -761,15 +752,10 @@ ProcRenderTrapezoids (ClientPtr client)
return BadMatch; return BadMatch;
if (stuff->maskFormat) if (stuff->maskFormat)
{ {
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
stuff->maskFormat, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
} }
else else
pFormat = 0; pFormat = 0;
@ -787,7 +773,7 @@ ProcRenderTrapezoids (ClientPtr client)
static int static int
ProcRenderTriangles (ClientPtr client) ProcRenderTriangles (ClientPtr client)
{ {
int ntris; int rc, ntris;
PicturePtr pSrc, pDst; PicturePtr pSrc, pDst;
PictFormatPtr pFormat; PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq); REQUEST(xRenderTrianglesReq);
@ -808,15 +794,10 @@ ProcRenderTriangles (ClientPtr client)
return BadMatch; return BadMatch;
if (stuff->maskFormat) if (stuff->maskFormat)
{ {
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
stuff->maskFormat, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
} }
else else
pFormat = 0; pFormat = 0;
@ -834,7 +815,7 @@ ProcRenderTriangles (ClientPtr client)
static int static int
ProcRenderTriStrip (ClientPtr client) ProcRenderTriStrip (ClientPtr client)
{ {
int npoints; int rc, npoints;
PicturePtr pSrc, pDst; PicturePtr pSrc, pDst;
PictFormatPtr pFormat; PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq); REQUEST(xRenderTrianglesReq);
@ -855,15 +836,10 @@ ProcRenderTriStrip (ClientPtr client)
return BadMatch; return BadMatch;
if (stuff->maskFormat) if (stuff->maskFormat)
{ {
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
stuff->maskFormat, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
} }
else else
pFormat = 0; pFormat = 0;
@ -881,7 +857,7 @@ ProcRenderTriStrip (ClientPtr client)
static int static int
ProcRenderTriFan (ClientPtr client) ProcRenderTriFan (ClientPtr client)
{ {
int npoints; int rc, npoints;
PicturePtr pSrc, pDst; PicturePtr pSrc, pDst;
PictFormatPtr pFormat; PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq); REQUEST(xRenderTrianglesReq);
@ -902,15 +878,10 @@ ProcRenderTriFan (ClientPtr client)
return BadMatch; return BadMatch;
if (stuff->maskFormat) if (stuff->maskFormat)
{ {
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
stuff->maskFormat, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
} }
else else
pFormat = 0; pFormat = 0;
@ -954,15 +925,11 @@ ProcRenderCreateGlyphSet (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
LEGAL_NEW_RESOURCE(stuff->gsid, client); LEGAL_NEW_RESOURCE(stuff->gsid, client);
format = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&format, stuff->format,
stuff->format, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!format)
{
client->errorValue = stuff->format;
return RenderErrBase + BadPictFormat;
}
switch (format->depth) { switch (format->depth) {
case 1: case 1:
f = GlyphFormat1; f = GlyphFormat1;
@ -1300,7 +1267,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
int nlist; int nlist;
int space; int space;
int size; int size;
int n; int rc, n;
REQUEST(xRenderCompositeGlyphsReq); REQUEST(xRenderCompositeGlyphsReq);
@ -1327,28 +1294,18 @@ ProcRenderCompositeGlyphs (ClientPtr client)
return BadMatch; return BadMatch;
if (stuff->maskFormat) if (stuff->maskFormat)
{ {
pFormat = (PictFormatPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
stuff->maskFormat, PictFormatType, client, DixReadAccess);
PictFormatType, if (rc != Success)
DixReadAccess); return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
if (!pFormat)
{
client->errorValue = stuff->maskFormat;
return RenderErrBase + BadPictFormat;
}
} }
else else
pFormat = 0; pFormat = 0;
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset,
stuff->glyphset, GlyphSetType, client, DixUseAccess);
GlyphSetType, if (rc != Success)
DixUseAccess); return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
if (!glyphSet)
{
client->errorValue = stuff->glyphset;
return RenderErrBase + BadGlyphSet;
}
buffer = (CARD8 *) (stuff + 1); buffer = (CARD8 *) (stuff + 1);
end = (CARD8 *) stuff + (client->req_len << 2); end = (CARD8 *) stuff + (client->req_len << 2);
@ -1402,18 +1359,16 @@ ProcRenderCompositeGlyphs (ClientPtr client)
if (buffer + sizeof (GlyphSet) < end) if (buffer + sizeof (GlyphSet) < end)
{ {
memcpy(&gs, buffer, sizeof(GlyphSet)); memcpy(&gs, buffer, sizeof(GlyphSet));
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, rc = dixLookupResourceByType((pointer *)&glyphSet, gs,
gs, GlyphSetType, client,
GlyphSetType,
DixUseAccess); DixUseAccess);
if (!glyphSet) if (rc != Success)
{ {
client->errorValue = gs;
if (glyphsBase != glyphsLocal) if (glyphsBase != glyphsLocal)
xfree (glyphsBase); xfree (glyphsBase);
if (listsBase != listsLocal) if (listsBase != listsLocal)
xfree (listsBase); xfree (listsBase);
return RenderErrBase + BadGlyphSet; return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
} }
} }
buffer += 4; buffer += 4;
@ -1902,13 +1857,12 @@ ProcRenderCreateAnimCursor (ClientPtr client)
elt = (xAnimCursorElt *) (stuff + 1); elt = (xAnimCursorElt *) (stuff + 1);
for (i = 0; i < ncursor; i++) for (i = 0; i < ncursor; i++)
{ {
cursors[i] = (CursorPtr)SecurityLookupIDByType(client, elt->cursor, ret = dixLookupResourceByType((pointer *)(cursors + 1), elt->cursor,
RT_CURSOR, DixReadAccess); RT_CURSOR, client, DixReadAccess);
if (!cursors[i]) if (ret != Success)
{ {
xfree (cursors); xfree (cursors);
client->errorValue = elt->cursor; return (ret == BadValue) ? BadCursor : ret;
return BadCursor;
} }
deltas[i] = elt->delay; deltas[i] = elt->delay;
elt++; elt++;
@ -2689,11 +2643,10 @@ SProcRenderDispatch (ClientPtr client)
#include "panoramiXsrv.h" #include "panoramiXsrv.h"
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\ #define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\ int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
if (!pPicture) { \ XRT_PICTURE, client, mode);\
client->errorValue = pid; \ if (rc != Success)\
return err; \ return (rc == BadValue) ? err : rc;\
} \
} }
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\ #define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\
@ -2713,12 +2666,13 @@ PanoramiXRenderCreatePicture (ClientPtr client)
{ {
REQUEST(xRenderCreatePictureReq); REQUEST(xRenderCreatePictureReq);
PanoramiXRes *refDraw, *newPict; PanoramiXRes *refDraw, *newPict;
int result = Success, j; int result, j;
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable,
client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) XRC_DRAWABLE, client, DixWriteAccess);
return BadDrawable; if (result != Success)
return (result == BadValue) ? BadDrawable : result;
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPict->type = XRT_PICTURE; newPict->type = XRT_PICTURE;

View File

@ -203,6 +203,8 @@ XFixesSelectCursorInput (ClientPtr pClient,
CARD32 eventMask) CARD32 eventMask)
{ {
CursorEventPtr *prev, e; CursorEventPtr *prev, e;
pointer val;
int rc;
for (prev = &cursorEvents; (e = *prev); prev = &e->next) for (prev = &cursorEvents; (e = *prev); prev = &e->next)
{ {
@ -235,7 +237,10 @@ XFixesSelectCursorInput (ClientPtr pClient,
* Add a resource hanging from the window to * Add a resource hanging from the window to
* catch window destroy * 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, if (!AddResource (pWindow->drawable.id, CursorWindowType,
(pointer) pWindow)) (pointer) pWindow))
{ {

View File

@ -133,6 +133,7 @@ XFixesSelectSelectionInput (ClientPtr pClient,
WindowPtr pWindow, WindowPtr pWindow,
CARD32 eventMask) CARD32 eventMask)
{ {
pointer val;
int rc; int rc;
SelectionEventPtr *prev, e; SelectionEventPtr *prev, e;
@ -173,7 +174,10 @@ XFixesSelectSelectionInput (ClientPtr pClient,
* Add a resource hanging from the window to * Add a resource hanging from the window to
* catch window destroy * 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, if (!AddResource (pWindow->drawable.id, SelectionWindowType,
(pointer) pWindow)) (pointer) pWindow))
{ {