This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-30 10:45:47 +02:00
parent b61647f3a1
commit acda27c35b
4 changed files with 47 additions and 8 deletions

View File

@ -920,6 +920,8 @@ ProcPanoramiXShmGetImage(ClientPtr client)
static int static int
ProcPanoramiXShmCreatePixmap(ClientPtr client) ProcPanoramiXShmCreatePixmap(ClientPtr client)
{ {
fprintf(stderr, "ProcPanoramiXShmCreatePixmap\n");
ScreenPtr pScreen = NULL; ScreenPtr pScreen = NULL;
PixmapPtr pMap = NULL; PixmapPtr pMap = NULL;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -1065,10 +1067,17 @@ ProcShmCreatePixmap(ClientPtr client)
unsigned int width, height, depth; unsigned int width, height, depth;
unsigned long size; unsigned long size;
fprintf(stderr, "ProcShmCreatePixmap\n");
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid; client->errorValue = stuff->pid;
if (!sharedPixmaps) if (!sharedPixmaps) {
fprintf(stderr, "ProcShmCreatePixmap: no shared pixmaps\n");
return BadImplementation; return BadImplementation;
}
fprintf(stderr, "ProcShmCreatePixmap: supporting shared pixmaps\n");
LEGAL_NEW_RESOURCE(stuff->pid, client); LEGAL_NEW_RESOURCE(stuff->pid, client);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
DixGetAttrAccess); DixGetAttrAccess);
@ -1077,34 +1086,48 @@ ProcShmCreatePixmap(ClientPtr client)
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
fprintf(stderr, "ProcShmCreatePixmap: 3\n");
width = stuff->width; width = stuff->width;
height = stuff->height; height = stuff->height;
depth = stuff->depth; depth = stuff->depth;
if (!width || !height || !depth) { if (!width || !height || !depth) {
client->errorValue = 0; client->errorValue = 0;
fprintf(stderr, "ProcShmCreatePixmap: broken dims %d %d %d\n", width, height, depth);
return BadValue; return BadValue;
} }
if (width > 32767 || height > 32767) if (width > 32767 || height > 32767) {
fprintf(stderr, "ProcShmCreatePixmap: out of memory %d %d %d\n", width, height, depth);
return BadAlloc; return BadAlloc;
}
if (stuff->depth != 1) { if (stuff->depth != 1) {
pDepth = pDraw->pScreen->allowedDepths; pDepth = pDraw->pScreen->allowedDepths;
for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++) for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++) {
fprintf(stderr, "ProcShmCreatePixmap() trying depth: have=%d want=%d\n", pDepth->depth, stuff->depth);
if (pDepth->depth == stuff->depth) if (pDepth->depth == stuff->depth)
goto CreatePmap; goto CreatePmap;
}
client->errorValue = stuff->depth; client->errorValue = stuff->depth;
fprintf(stderr, "ProcShmCreatePixmap: not allowed screen depth %d %d %d\n", width, height, depth);
return BadValue; return BadValue;
} }
CreatePmap: CreatePmap:
size = PixmapBytePad(width, depth) * height; size = PixmapBytePad(width, depth) * height;
if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
if (size < width * height) if (size < width * height) {
fprintf(stderr, "shm stoo small\n");
return BadAlloc; return BadAlloc;
} }
}
/* thankfully, offset is unsigned */ /* thankfully, offset is unsigned */
if (stuff->offset + size < size) if (stuff->offset + size < size) {
fprintf(stderr, "out of segment\n");
return BadAlloc; return BadAlloc;
}
fprintf(stderr, "4\n");
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
screen_priv = ShmGetScreenPriv(pDraw->pScreen); screen_priv = ShmGetScreenPriv(pDraw->pScreen);
@ -1112,10 +1135,13 @@ ProcShmCreatePixmap(ClientPtr client)
stuff->height, stuff->depth, stuff->height, stuff->depth,
shmdesc->addr + shmdesc->addr +
stuff->offset); stuff->offset);
fprintf(stderr, "called shmfuncs->CreatePixmap\n");
if (pMap) { if (pMap) {
fprintf(stderr, "got pMap\n");
rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP,
pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) { if (rc != Success) {
fprintf(stderr, "xace denied\n");
dixDestroyPixmap(pMap, 0); dixDestroyPixmap(pMap, 0);
return rc; return rc;
} }
@ -1124,9 +1150,12 @@ ProcShmCreatePixmap(ClientPtr client)
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid; pMap->drawable.id = stuff->pid;
if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) { if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) {
fprintf(stderr, "CreatePixmap() Success\n");
return Success; return Success;
} }
fprintf(stderr, "failed adding resource\n");
} }
fprintf(stderr, "shmfuncs->CreatePixmap() failed\n");
return BadAlloc; return BadAlloc;
} }
@ -1335,6 +1364,8 @@ ProcShmCreateSegment(ClientPtr client)
static int static int
ProcShmDispatch(ClientPtr client) ProcShmDispatch(ClientPtr client)
{ {
fprintf(stderr, "ProcShmDispatch\n");
REQUEST(xReq); REQUEST(xReq);
if (stuff->data == X_ShmQueryVersion) if (stuff->data == X_ShmQueryVersion)

View File

@ -91,6 +91,8 @@ xnestOpenDisplay(int argc, char *argv[])
if (xnestNumVisuals == 0 || xnestVisuals == NULL) if (xnestNumVisuals == 0 || xnestVisuals == NULL)
FatalError("Unable to find any visuals.\n"); FatalError("Unable to find any visuals.\n");
fprintf(stderr, "got %d visuals\n", xnestNumVisuals);
if (xnestUserDefaultClass || xnestUserDefaultDepth) { if (xnestUserDefaultClass || xnestUserDefaultDepth) {
xnestDefaultVisualIndex = UNDEFINED; xnestDefaultVisualIndex = UNDEFINED;
for (i = 0; i < xnestNumVisuals; i++) for (i = 0; i < xnestNumVisuals; i++)
@ -143,14 +145,15 @@ xnestOpenDisplay(int argc, char *argv[])
xnestDefaultDrawables[i] = None; xnestDefaultDrawables[i] = None;
for (i = 0; i < xnestNumPixmapFormats; i++) for (i = 0; i < xnestNumPixmapFormats; i++)
for (j = 0; j < xnestNumDepths; j++) for (j = 0; j < xnestNumDepths; j++) {
fprintf(stderr, "pixfmt #%d depth #%d: xnestDepth=%d\n", i, j, xnestDepths[j]);
if (xnestPixmapFormats[i].depth == 1 || if (xnestPixmapFormats[i].depth == 1 ||
xnestPixmapFormats[i].depth == xnestDepths[j]) { xnestPixmapFormats[i].depth == xnestDepths[j]) {
xnestDefaultDrawables[xnestPixmapFormats[i].depth] = xnestDefaultDrawables[xnestPixmapFormats[i].depth] =
XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay), XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay),
1, 1, xnestPixmapFormats[i].depth); 1, 1, xnestPixmapFormats[i].depth);
} }
}
xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL);
if (!(xnestUserGeometry & XValue)) if (!(xnestUserGeometry & XValue))

View File

@ -173,7 +173,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
depths[0].vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); depths[0].vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
numDepths = 1; numDepths = 1;
fprintf(stderr, "xnestNumVisuals=%d\n", xnestNumVisuals);
for (i = 0; i < xnestNumVisuals; i++) { for (i = 0; i < xnestNumVisuals; i++) {
fprintf(stderr, "visual #%d planes=%d\n", i, xnestVisuals[i].depth);
visuals[numVisuals].class = xnestVisuals[i].class; visuals[numVisuals].class = xnestVisuals[i].class;
visuals[numVisuals].bitsPerRGBValue = xnestVisuals[i].bits_per_rgb; visuals[numVisuals].bitsPerRGBValue = xnestVisuals[i].bits_per_rgb;
visuals[numVisuals].ColormapEntries = xnestVisuals[i].colormap_size; visuals[numVisuals].ColormapEntries = xnestVisuals[i].colormap_size;
@ -207,6 +210,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
visuals[numVisuals].vid = FakeClientID(0); visuals[numVisuals].vid = FakeClientID(0);
depthIndex = UNDEFINED; depthIndex = UNDEFINED;
fprintf(stderr, "OpenScreen: numDepths=%d\n", numDepths);
for (j = 0; j < numDepths; j++) for (j = 0; j < numDepths; j++)
if (depths[j].depth == xnestVisuals[i].depth) { if (depths[j].depth == xnestVisuals[i].depth) {
depthIndex = j; depthIndex = j;
@ -219,6 +223,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
depths[depthIndex].numVids = 0; depths[depthIndex].numVids = 0;
depths[depthIndex].vids = depths[depthIndex].vids =
(VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
fprintf(stderr, "added depth: %d\n", depths[depthIndex].depth);
numDepths++; numDepths++;
} }
if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) { if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) {

View File

@ -33,7 +33,7 @@ executable(
libxserver_xi_stubs, libxserver_xi_stubs,
libxserver_xkb_stubs, libxserver_xkb_stubs,
], ],
c_args: [ '-DHAVE_XNEST_CONFIG_H', '-DDISABLE_EXT_COMPOSITE', '-DDISABLE_EXT_DPMS', '-DISABLE_EXT_MITSHM' ], c_args: [ '-DHAVE_XNEST_CONFIG_H', '-DDISABLE_EXT_COMPOSITE', '-DDISABLE_EXT_DPMS' ],
install: true, install: true,
) )