xace: add hooks + new access codes: core protocol colormap requests
This commit is contained in:
parent
acc9a42c92
commit
d744df32a1
|
@ -64,6 +64,7 @@ SOFTWARE.
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "windowstr.h"
|
#include "windowstr.h"
|
||||||
#include "privates.h"
|
#include "privates.h"
|
||||||
|
#include "xace.h"
|
||||||
|
|
||||||
extern XID clientErrorValue;
|
extern XID clientErrorValue;
|
||||||
extern int colormapPrivateCount;
|
extern int colormapPrivateCount;
|
||||||
|
@ -412,6 +413,16 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Security creation/labeling check
|
||||||
|
*/
|
||||||
|
i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP,
|
||||||
|
DixCreateAccess, pmap);
|
||||||
|
if (i != Success) {
|
||||||
|
FreeResource(mid, RT_NONE);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(*pScreen->CreateColormap)(pmap))
|
if (!(*pScreen->CreateColormap)(pmap))
|
||||||
{
|
{
|
||||||
FreeResource (mid, RT_NONE);
|
FreeResource (mid, RT_NONE);
|
||||||
|
|
226
dix/dispatch.c
226
dix/dispatch.c
|
@ -2495,7 +2495,7 @@ ProcCreateColormap(ClientPtr client)
|
||||||
}
|
}
|
||||||
mid = stuff->mid;
|
mid = stuff->mid;
|
||||||
LEGAL_NEW_RESOURCE(mid, client);
|
LEGAL_NEW_RESOURCE(mid, client);
|
||||||
result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
|
result = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
||||||
if (result != Success)
|
if (result != Success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -2521,12 +2521,13 @@ int
|
||||||
ProcFreeColormap(ClientPtr client)
|
ProcFreeColormap(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pmap;
|
ColormapPtr pmap;
|
||||||
|
int rc;
|
||||||
REQUEST(xResourceReq);
|
REQUEST(xResourceReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xResourceReq);
|
REQUEST_SIZE_MATCH(xResourceReq);
|
||||||
pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
|
rc = dixLookupResource((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
|
||||||
DixDestroyAccess);
|
DixDestroyAccess);
|
||||||
if (pmap)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
/* Freeing a default colormap is a no-op */
|
/* Freeing a default colormap is a no-op */
|
||||||
if (!(pmap->flags & IsDefault))
|
if (!(pmap->flags & IsDefault))
|
||||||
|
@ -2536,7 +2537,7 @@ ProcFreeColormap(ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->id;
|
client->errorValue = stuff->id;
|
||||||
return (BadColor);
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2547,24 +2548,25 @@ ProcCopyColormapAndFree(ClientPtr client)
|
||||||
Colormap mid;
|
Colormap mid;
|
||||||
ColormapPtr pSrcMap;
|
ColormapPtr pSrcMap;
|
||||||
REQUEST(xCopyColormapAndFreeReq);
|
REQUEST(xCopyColormapAndFreeReq);
|
||||||
int result;
|
int rc;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
|
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
|
||||||
mid = stuff->mid;
|
mid = stuff->mid;
|
||||||
LEGAL_NEW_RESOURCE(mid, client);
|
LEGAL_NEW_RESOURCE(mid, client);
|
||||||
if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap,
|
rc = dixLookupResource((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
|
||||||
RT_COLORMAP, DixReadAccess|DixWriteAccess)) )
|
client, DixReadAccess|DixRemoveAccess);
|
||||||
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
result = CopyColormapAndFree(mid, pSrcMap, client->index);
|
rc = CopyColormapAndFree(mid, pSrcMap, client->index);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return(result);
|
return rc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->srcCmap;
|
client->errorValue = stuff->srcCmap;
|
||||||
return(BadColor);
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2572,43 +2574,51 @@ int
|
||||||
ProcInstallColormap(ClientPtr client)
|
ProcInstallColormap(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xResourceReq);
|
REQUEST(xResourceReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xResourceReq);
|
REQUEST_SIZE_MATCH(xResourceReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
|
|
||||||
RT_COLORMAP, DixReadAccess);
|
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
|
||||||
if (pcmp)
|
DixInstallAccess);
|
||||||
{
|
if (rc != Success)
|
||||||
(*(pcmp->pScreen->InstallColormap)) (pcmp);
|
goto out;
|
||||||
return (client->noClientException);
|
|
||||||
}
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
||||||
else
|
if (rc != Success)
|
||||||
{
|
goto out;
|
||||||
client->errorValue = stuff->id;
|
|
||||||
return (BadColor);
|
(*(pcmp->pScreen->InstallColormap)) (pcmp);
|
||||||
}
|
|
||||||
|
rc = client->noClientException;
|
||||||
|
out:
|
||||||
|
client->errorValue = stuff->id;
|
||||||
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ProcUninstallColormap(ClientPtr client)
|
ProcUninstallColormap(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xResourceReq);
|
REQUEST(xResourceReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xResourceReq);
|
REQUEST_SIZE_MATCH(xResourceReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
|
|
||||||
RT_COLORMAP, DixReadAccess);
|
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
|
||||||
if (pcmp)
|
DixUninstallAccess);
|
||||||
{
|
if (rc != Success)
|
||||||
if(pcmp->mid != pcmp->pScreen->defColormap)
|
goto out;
|
||||||
(*(pcmp->pScreen->UninstallColormap)) (pcmp);
|
|
||||||
return (client->noClientException);
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
||||||
}
|
if (rc != Success)
|
||||||
else
|
goto out;
|
||||||
{
|
|
||||||
client->errorValue = stuff->id;
|
if(pcmp->mid != pcmp->pScreen->defColormap)
|
||||||
return (BadColor);
|
(*(pcmp->pScreen->UninstallColormap)) (pcmp);
|
||||||
}
|
|
||||||
|
rc = client->noClientException;
|
||||||
|
out:
|
||||||
|
client->errorValue = stuff->id;
|
||||||
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -2618,11 +2628,16 @@ ProcListInstalledColormaps(ClientPtr client)
|
||||||
int nummaps, rc;
|
int nummaps, rc;
|
||||||
WindowPtr pWin;
|
WindowPtr pWin;
|
||||||
REQUEST(xResourceReq);
|
REQUEST(xResourceReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xResourceReq);
|
REQUEST_SIZE_MATCH(xResourceReq);
|
||||||
rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
|
|
||||||
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
goto out;
|
||||||
|
|
||||||
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
|
||||||
|
DixGetAttrAccess);
|
||||||
|
if (rc != Success)
|
||||||
|
goto out;
|
||||||
|
|
||||||
preply = (xListInstalledColormapsReply *)
|
preply = (xListInstalledColormapsReply *)
|
||||||
ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
|
ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
|
||||||
|
@ -2641,21 +2656,23 @@ ProcListInstalledColormaps(ClientPtr client)
|
||||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
||||||
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
|
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
|
||||||
DEALLOCATE_LOCAL(preply);
|
DEALLOCATE_LOCAL(preply);
|
||||||
return(client->noClientException);
|
rc = client->noClientException;
|
||||||
|
out:
|
||||||
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ProcAllocColor (ClientPtr client)
|
ProcAllocColor (ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pmap;
|
ColormapPtr pmap;
|
||||||
int retval;
|
int rc;
|
||||||
xAllocColorReply acr;
|
xAllocColorReply acr;
|
||||||
REQUEST(xAllocColorReq);
|
REQUEST(xAllocColorReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xAllocColorReq);
|
REQUEST_SIZE_MATCH(xAllocColorReq);
|
||||||
pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixAddAccess);
|
||||||
if (pmap)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
acr.type = X_Reply;
|
acr.type = X_Reply;
|
||||||
acr.length = 0;
|
acr.length = 0;
|
||||||
|
@ -2664,13 +2681,13 @@ ProcAllocColor (ClientPtr client)
|
||||||
acr.green = stuff->green;
|
acr.green = stuff->green;
|
||||||
acr.blue = stuff->blue;
|
acr.blue = stuff->blue;
|
||||||
acr.pixel = 0;
|
acr.pixel = 0;
|
||||||
if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
|
if( (rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
|
||||||
&acr.pixel, client->index)) )
|
&acr.pixel, client->index)) )
|
||||||
{
|
{
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return (retval);
|
return rc;
|
||||||
}
|
}
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
if (noPanoramiXExtension || !pmap->pScreen->myNum)
|
if (noPanoramiXExtension || !pmap->pScreen->myNum)
|
||||||
|
@ -2682,7 +2699,7 @@ ProcAllocColor (ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2690,15 +2707,14 @@ int
|
||||||
ProcAllocNamedColor (ClientPtr client)
|
ProcAllocNamedColor (ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xAllocNamedColorReq);
|
REQUEST(xAllocNamedColorReq);
|
||||||
|
|
||||||
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
|
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixAddAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
int retval;
|
|
||||||
|
|
||||||
xAllocNamedColorReply ancr;
|
xAllocNamedColorReply ancr;
|
||||||
|
|
||||||
ancr.type = X_Reply;
|
ancr.type = X_Reply;
|
||||||
|
@ -2712,14 +2728,14 @@ ProcAllocNamedColor (ClientPtr client)
|
||||||
ancr.screenGreen = ancr.exactGreen;
|
ancr.screenGreen = ancr.exactGreen;
|
||||||
ancr.screenBlue = ancr.exactBlue;
|
ancr.screenBlue = ancr.exactBlue;
|
||||||
ancr.pixel = 0;
|
ancr.pixel = 0;
|
||||||
if( (retval = AllocColor(pcmp,
|
if( (rc = AllocColor(pcmp,
|
||||||
&ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
|
&ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
|
||||||
&ancr.pixel, client->index)) )
|
&ancr.pixel, client->index)) )
|
||||||
{
|
{
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
||||||
|
@ -2734,7 +2750,7 @@ ProcAllocNamedColor (ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2742,15 +2758,16 @@ int
|
||||||
ProcAllocColorCells (ClientPtr client)
|
ProcAllocColorCells (ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xAllocColorCellsReq);
|
REQUEST(xAllocColorCellsReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
|
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixAddAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
xAllocColorCellsReply accr;
|
xAllocColorCellsReply accr;
|
||||||
int npixels, nmasks, retval;
|
int npixels, nmasks;
|
||||||
long length;
|
long length;
|
||||||
Pixel *ppixels, *pmasks;
|
Pixel *ppixels, *pmasks;
|
||||||
|
|
||||||
|
@ -2772,14 +2789,14 @@ ProcAllocColorCells (ClientPtr client)
|
||||||
return(BadAlloc);
|
return(BadAlloc);
|
||||||
pmasks = ppixels + npixels;
|
pmasks = ppixels + npixels;
|
||||||
|
|
||||||
if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks,
|
if( (rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
|
||||||
(Bool)stuff->contiguous, ppixels, pmasks)) )
|
(Bool)stuff->contiguous, ppixels, pmasks)) )
|
||||||
{
|
{
|
||||||
DEALLOCATE_LOCAL(ppixels);
|
DEALLOCATE_LOCAL(ppixels);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
||||||
|
@ -2800,7 +2817,7 @@ ProcAllocColorCells (ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2808,15 +2825,16 @@ int
|
||||||
ProcAllocColorPlanes(ClientPtr client)
|
ProcAllocColorPlanes(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xAllocColorPlanesReq);
|
REQUEST(xAllocColorPlanesReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
|
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixAddAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
xAllocColorPlanesReply acpr;
|
xAllocColorPlanesReply acpr;
|
||||||
int npixels, retval;
|
int npixels;
|
||||||
long length;
|
long length;
|
||||||
Pixel *ppixels;
|
Pixel *ppixels;
|
||||||
|
|
||||||
|
@ -2838,7 +2856,7 @@ ProcAllocColorPlanes(ClientPtr client)
|
||||||
ppixels = (Pixel *)ALLOCATE_LOCAL(length);
|
ppixels = (Pixel *)ALLOCATE_LOCAL(length);
|
||||||
if(!ppixels)
|
if(!ppixels)
|
||||||
return(BadAlloc);
|
return(BadAlloc);
|
||||||
if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
|
if( (rc = AllocColorPlanes(client->index, pcmp, npixels,
|
||||||
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
|
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
|
||||||
(Bool)stuff->contiguous, ppixels,
|
(Bool)stuff->contiguous, ppixels,
|
||||||
&acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
|
&acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
|
||||||
|
@ -2847,7 +2865,7 @@ ProcAllocColorPlanes(ClientPtr client)
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
acpr.length = length >> 2;
|
acpr.length = length >> 2;
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
|
@ -2864,7 +2882,7 @@ ProcAllocColorPlanes(ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2872,34 +2890,34 @@ int
|
||||||
ProcFreeColors(ClientPtr client)
|
ProcFreeColors(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xFreeColorsReq);
|
REQUEST(xFreeColorsReq);
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
|
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixRemoveAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
int retval;
|
|
||||||
|
|
||||||
if(pcmp->flags & AllAllocated)
|
if(pcmp->flags & AllAllocated)
|
||||||
return(BadAccess);
|
return(BadAccess);
|
||||||
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
|
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
|
||||||
retval = FreeColors(pcmp, client->index, count,
|
rc = FreeColors(pcmp, client->index, count,
|
||||||
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
|
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = clientErrorValue;
|
client->errorValue = clientErrorValue;
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2907,33 +2925,33 @@ int
|
||||||
ProcStoreColors (ClientPtr client)
|
ProcStoreColors (ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xStoreColorsReq);
|
REQUEST(xStoreColorsReq);
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
|
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixWriteAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
int retval;
|
|
||||||
|
|
||||||
count = (client->req_len << 2) - sizeof(xStoreColorsReq);
|
count = (client->req_len << 2) - sizeof(xStoreColorsReq);
|
||||||
if (count % sizeof(xColorItem))
|
if (count % sizeof(xColorItem))
|
||||||
return(BadLength);
|
return(BadLength);
|
||||||
count /= sizeof(xColorItem);
|
count /= sizeof(xColorItem);
|
||||||
retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
|
rc = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = clientErrorValue;
|
client->errorValue = clientErrorValue;
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2941,33 +2959,33 @@ int
|
||||||
ProcStoreNamedColor (ClientPtr client)
|
ProcStoreNamedColor (ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xStoreNamedColorReq);
|
REQUEST(xStoreNamedColorReq);
|
||||||
|
|
||||||
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
|
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixWriteAccess);
|
DixWriteAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
xColorItem def;
|
xColorItem def;
|
||||||
int retval;
|
|
||||||
|
|
||||||
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
|
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
|
||||||
stuff->nbytes, &def.red, &def.green, &def.blue))
|
stuff->nbytes, &def.red, &def.green, &def.blue))
|
||||||
{
|
{
|
||||||
def.flags = stuff->flags;
|
def.flags = stuff->flags;
|
||||||
def.pixel = stuff->pixel;
|
def.pixel = stuff->pixel;
|
||||||
retval = StoreColors(pcmp, 1, &def);
|
rc = StoreColors(pcmp, 1, &def);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
else
|
else
|
||||||
return(retval);
|
return rc;
|
||||||
}
|
}
|
||||||
return (BadName);
|
return (BadName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2975,14 +2993,15 @@ int
|
||||||
ProcQueryColors(ClientPtr client)
|
ProcQueryColors(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xQueryColorsReq);
|
REQUEST(xQueryColorsReq);
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
|
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixReadAccess);
|
DixReadAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
int count, retval;
|
int count;
|
||||||
xrgb *prgbs;
|
xrgb *prgbs;
|
||||||
xQueryColorsReply qcr;
|
xQueryColorsReply qcr;
|
||||||
|
|
||||||
|
@ -2990,7 +3009,7 @@ ProcQueryColors(ClientPtr client)
|
||||||
prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
|
prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
|
||||||
if(!prgbs && count)
|
if(!prgbs && count)
|
||||||
return(BadAlloc);
|
return(BadAlloc);
|
||||||
if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
|
if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
|
||||||
{
|
{
|
||||||
if (prgbs) DEALLOCATE_LOCAL(prgbs);
|
if (prgbs) DEALLOCATE_LOCAL(prgbs);
|
||||||
if (client->noClientException != Success)
|
if (client->noClientException != Success)
|
||||||
|
@ -2998,7 +3017,7 @@ ProcQueryColors(ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = clientErrorValue;
|
client->errorValue = clientErrorValue;
|
||||||
return (retval);
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qcr.type = X_Reply;
|
qcr.type = X_Reply;
|
||||||
|
@ -3018,7 +3037,7 @@ ProcQueryColors(ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3026,12 +3045,13 @@ int
|
||||||
ProcLookupColor(ClientPtr client)
|
ProcLookupColor(ClientPtr client)
|
||||||
{
|
{
|
||||||
ColormapPtr pcmp;
|
ColormapPtr pcmp;
|
||||||
|
int rc;
|
||||||
REQUEST(xLookupColorReq);
|
REQUEST(xLookupColorReq);
|
||||||
|
|
||||||
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
|
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
|
||||||
pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
|
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
||||||
RT_COLORMAP, DixReadAccess);
|
DixReadAccess);
|
||||||
if (pcmp)
|
if (rc == Success)
|
||||||
{
|
{
|
||||||
xLookupColorReply lcr;
|
xLookupColorReply lcr;
|
||||||
|
|
||||||
|
@ -3056,7 +3076,7 @@ ProcLookupColor(ClientPtr client)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->errorValue = stuff->cmap;
|
client->errorValue = stuff->cmap;
|
||||||
return (BadColor);
|
return (rc == BadValue) ? BadColor : rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue