diff --git a/Xi/chaccess.c b/Xi/chaccess.c index 5005e9435..f09920600 100644 --- a/Xi/chaccess.c +++ b/Xi/chaccess.c @@ -65,7 +65,7 @@ int ProcXChangeWindowAccess(ClientPtr client) { int padding, err, i; - CARD8* deviceids = NULL; + XID* deviceids = NULL; WindowPtr win; DeviceIntPtr* perm_devices = NULL; DeviceIntPtr* deny_devices = NULL; @@ -73,10 +73,10 @@ ProcXChangeWindowAccess(ClientPtr client) REQUEST_AT_LEAST_SIZE(xChangeWindowAccessReq); - padding = (4 - ((stuff->npermit + stuff->ndeny) % 4)) % 4; + padding = (4 - (((stuff->npermit + stuff->ndeny) * sizeof(XID)) % 4)) % 4; if (stuff->length != ((sizeof(xChangeWindowAccessReq) + - (stuff->npermit + stuff->ndeny + padding)) >> 2)) + (((stuff->npermit + stuff->ndeny) * sizeof(XID)) + padding)) >> 2)) { SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0, BadLength); @@ -102,7 +102,7 @@ ProcXChangeWindowAccess(ClientPtr client) } if (stuff->npermit || stuff->ndeny) - deviceids = (CARD8*)&stuff[1]; + deviceids = (XID*)&stuff[1]; if (stuff->npermit) { diff --git a/Xi/qryacces.c b/Xi/qryacces.c index 817bec8a3..b59696939 100644 --- a/Xi/qryacces.c +++ b/Xi/qryacces.c @@ -69,7 +69,7 @@ ProcXQueryWindowAccess(ClientPtr client) DeviceIntPtr *perm, *deny; int nperm, ndeny, i; int defaultRule; - CARD8* deviceids; + XID* deviceids; xQueryWindowAccessReply rep; REQUEST(xQueryWindowAccessReq); @@ -88,7 +88,7 @@ ProcXQueryWindowAccess(ClientPtr client) rep.repType = X_Reply; rep.RepType = X_QueryWindowAccess; rep.sequenceNumber = client->sequence; - rep.length = (nperm + ndeny + 3) >> 2; + rep.length = ((nperm + ndeny) * sizeof(XID) + 3) >> 2; rep.defaultRule = defaultRule; rep.npermit = nperm; rep.ndeny = ndeny; @@ -96,7 +96,7 @@ ProcXQueryWindowAccess(ClientPtr client) if (nperm + ndeny) { - deviceids = (CARD8*)xalloc((nperm + ndeny) * sizeof(CARD8)); + deviceids = (XID*)xalloc((nperm + ndeny) * sizeof(XID)); if (!deviceids) { ErrorF("ProcXQueryWindowAccess: xalloc failure.\n"); @@ -110,7 +110,7 @@ ProcXQueryWindowAccess(ClientPtr client) for (i = 0; i < ndeny; i++) deviceids[i + nperm] = deny[i]->id; - WriteToClient(client, nperm + ndeny, (char*)deviceids); + WriteToClient(client, (nperm + ndeny) * sizeof(XID), (char*)deviceids); xfree(deviceids); } return Success;