summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
Diffstat (limited to 'Xext')
-rw-r--r--Xext/bigreq.c2
-rw-r--r--Xext/dpms.c21
-rw-r--r--Xext/mbuf.c10
-rw-r--r--Xext/panoramiX.c4
-rw-r--r--Xext/panoramiXprocs.c18
-rw-r--r--Xext/saver.c7
-rw-r--r--Xext/security.c18
-rw-r--r--Xext/shape.c5
-rw-r--r--Xext/shm.c3
-rw-r--r--Xext/shmint.h30
-rw-r--r--Xext/sync.c50
-rw-r--r--Xext/xace.c118
-rw-r--r--Xext/xace.h2
-rw-r--r--Xext/xacestr.h2
-rw-r--r--Xext/xcmisc.c2
-rw-r--r--Xext/xf86bigfont.c5
-rw-r--r--Xext/xres.c4
-rw-r--r--Xext/xselinux.c22
-rw-r--r--Xext/xselinux.h6
-rw-r--r--Xext/xtest.c199
-rw-r--r--Xext/xvdisp.c19
-rw-r--r--Xext/xvmc.c8
22 files changed, 351 insertions, 204 deletions
diff --git a/Xext/bigreq.c b/Xext/bigreq.c
index e50376c6e..582b670b0 100644
--- a/Xext/bigreq.c
+++ b/Xext/bigreq.c
@@ -36,7 +36,7 @@ from The Open Group.
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
-#include <X11/extensions/bigreqstr.h>
+#include <X11/extensions/bigreqsproto.h>
#include "opaque.h"
#include "modinit.h"
diff --git a/Xext/dpms.c b/Xext/dpms.c
index 8464f9e98..df63a8bf1 100644
--- a/Xext/dpms.c
+++ b/Xext/dpms.c
@@ -37,9 +37,7 @@ Equipment Corporation.
#include "dixstruct.h"
#include "extnsionst.h"
#include "opaque.h"
-#define DPMS_SERVER
-#include <X11/extensions/dpms.h>
-#include <X11/extensions/dpmsstr.h>
+#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
#include "modinit.h"
@@ -179,19 +177,10 @@ ProcDPMSForceLevel(ClientPtr client)
if (!DPMSEnabled)
return BadMatch;
- if (stuff->level == DPMSModeOn) {
- lastDeviceEventTime.milliseconds =
- GetTimeInMillis();
- } else if (stuff->level == DPMSModeStandby) {
- lastDeviceEventTime.milliseconds =
- GetTimeInMillis() - DPMSStandbyTime;
- } else if (stuff->level == DPMSModeSuspend) {
- lastDeviceEventTime.milliseconds =
- GetTimeInMillis() - DPMSSuspendTime;
- } else if (stuff->level == DPMSModeOff) {
- lastDeviceEventTime.milliseconds =
- GetTimeInMillis() - DPMSOffTime;
- } else {
+ if (stuff->level != DPMSModeOn &&
+ stuff->level != DPMSModeStandby &&
+ stuff->level != DPMSModeSuspend &&
+ stuff->level != DPMSModeOff) {
client->errorValue = stuff->level;
return BadValue;
}
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index 09399b65e..55e732a9f 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -430,7 +430,7 @@ ProcCreateImageBuffers (client)
int len, nbuf, i, err, rc;
REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
- len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xMbufCreateImageBuffersReq));
if (len == 0)
return BadLength;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
@@ -498,7 +498,7 @@ ProcDisplayImageBuffers (client)
REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
- nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2);
+ nbuf = stuff->length - bytes_to_int32(sizeof (xMbufDisplayImageBuffersReq));
if (!nbuf)
return Success;
minDelay = stuff->minDelay;
@@ -592,7 +592,7 @@ ProcSetMBufferAttributes (client)
pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
if (!pMultibuffers)
return BadMatch;
- len = stuff->length - (sizeof (xMbufSetMBufferAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq));
vmask = stuff->valueMask;
if (len != Ones (vmask))
return BadLength;
@@ -687,7 +687,7 @@ ProcSetBufferAttributes (client)
pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
if (!pMultibuffer)
return MultibufferErrorBase + MultibufferBadBuffer;
- len = stuff->length - (sizeof (xMbufSetBufferAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq));
vmask = stuff->valueMask;
if (len != Ones (vmask))
return BadLength;
@@ -787,7 +787,7 @@ ProcGetBufferInfo (client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.length = nInfo * (sizeof (xMbufBufferInfo) >> 2);
+ rep.length = nInfo * bytes_to_int32(sizeof (xMbufBufferInfo));
rep.normalInfo = nInfo;
rep.stereoInfo = 0;
if (client->swapped)
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 4ab6f6bdd..c5fb70061 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -669,7 +669,7 @@ Bool PanoramiXCreateConnectionBlock(void)
length += (depth->nVisuals * sizeof(xVisualType));
}
- connSetupPrefix.length = length >> 2;
+ connSetupPrefix.length = bytes_to_int32(length);
for (i = 0; i < PanoramiXNumDepths; i++)
xfree(PanoramiXDepths[i].vids);
@@ -1053,7 +1053,7 @@ ProcXineramaQueryScreens(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
- rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+ rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 8b51009b3..6834efb71 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -74,7 +74,7 @@ int PanoramiXCreateWindow(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
- len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -179,7 +179,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
- len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq));
if (Ones(stuff->valueMask) != len)
return BadLength;
@@ -456,7 +456,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
- len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -734,7 +734,7 @@ int PanoramiXCreateGC(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
client->errorValue = stuff->gc;
- len = client->req_len - (sizeof(xCreateGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -813,7 +813,7 @@ int PanoramiXChangeGC(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
- len = client->req_len - (sizeof(xChangeGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -1299,7 +1299,7 @@ int PanoramiXPolyPoint(ClientPtr client)
return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
origPts = xalloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
@@ -1359,7 +1359,7 @@ int PanoramiXPolyLine(ClientPtr client)
return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0){
origPts = xalloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
@@ -1605,7 +1605,7 @@ int PanoramiXFillPoly(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+ count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0){
locPts = xalloc(count * sizeof(DDXPointRec));
memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec));
@@ -1895,7 +1895,7 @@ int PanoramiXGetImage(ClientPtr client)
}
- xgi.length = (length + 3) >> 2;
+ xgi.length = bytes_to_int32(length);
if (widthBytesLine == 0 || h == 0)
linesPerBuf = 0;
diff --git a/Xext/saver.c b/Xext/saver.c
index b59f769d5..18de4b540 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -52,8 +52,7 @@ in this Software without prior written authorization from the X Consortium.
#include "panoramiXsrv.h"
#endif
#ifdef DPMSExtension
-#define DPMS_SERVER
-#include <X11/extensions/dpms.h>
+#include <X11/extensions/dpmsconst.h>
#endif
#include <stdio.h>
@@ -875,7 +874,7 @@ ScreenSaverSetAttributes (ClientPtr client)
if (ret != Success)
return ret;
- len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height)
@@ -1267,7 +1266,7 @@ ProcScreenSaverSetAttributes (ClientPtr client)
if (status != Success)
return (status == BadValue) ? BadDrawable : status;
- len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
diff --git a/Xext/security.c b/Xext/security.c
index bae95a3b5..42eb9f01d 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -37,7 +37,7 @@ in this Software without prior written authorization from The Open Group.
#include "registry.h"
#include "xacestr.h"
#include "securitysrv.h"
-#include <X11/extensions/securstr.h>
+#include <X11/extensions/securproto.h>
#include "modinit.h"
/* Extension stuff */
@@ -450,9 +450,9 @@ ProcSecurityGenerateAuthorization(
/* check request length */
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
- len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2;
- len += (stuff->nbytesAuthProto + (unsigned)3) >> 2;
- len += (stuff->nbytesAuthData + (unsigned)3) >> 2;
+ len = bytes_to_int32(SIZEOF(xSecurityGenerateAuthorizationReq));
+ len += bytes_to_int32(stuff->nbytesAuthProto);
+ len += bytes_to_int32(stuff->nbytesAuthData);
values = ((CARD32 *)stuff) + len;
len += Ones(stuff->valueMask);
if (client->req_len != len)
@@ -520,7 +520,7 @@ ProcSecurityGenerateAuthorization(
}
protoname = (char *)&stuff[1];
- protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2);
+ protodata = protoname + bytes_to_int32(stuff->nbytesAuthProto);
/* call os layer to generate the authorization */
@@ -580,7 +580,7 @@ ProcSecurityGenerateAuthorization(
/* tell client the auth id and data */
rep.type = X_Reply;
- rep.length = (authdata_len + 3) >> 2;
+ rep.length = bytes_to_int32(authdata_len);
rep.sequenceNumber = client->sequence;
rep.authId = authId;
rep.dataLength = authdata_len;
@@ -688,10 +688,10 @@ SProcSecurityGenerateAuthorization(
swaps(&stuff->nbytesAuthProto, n);
swaps(&stuff->nbytesAuthData, n);
swapl(&stuff->valueMask, n);
- values_offset = ((stuff->nbytesAuthProto + (unsigned)3) >> 2) +
- ((stuff->nbytesAuthData + (unsigned)3) >> 2);
+ values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
+ bytes_to_int32(stuff->nbytesAuthData);
if (values_offset >
- stuff->length - (sz_xSecurityGenerateAuthorizationReq >> 2))
+ stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq))
return BadLength;
values = (CARD32 *)(&stuff[1]) + values_offset;
nvalues = (((CARD32 *)stuff) + stuff->length) - values;
diff --git a/Xext/shape.c b/Xext/shape.c
index 5977296e5..53167d140 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -41,8 +41,7 @@ in this Software without prior written authorization from The Open Group.
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
-#define _SHAPE_SERVER_ /* don't want Xlib structures */
-#include <X11/extensions/shapestr.h>
+#include <X11/extensions/shapeproto.h>
#include "regionstr.h"
#include "gcstruct.h"
#include "modinit.h"
@@ -1069,7 +1068,7 @@ ProcShapeGetRectangles (ClientPtr client)
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.length = (nrects * sizeof (xRectangle)) >> 2;
+ rep.length = bytes_to_int32(nrects * sizeof (xRectangle));
rep.ordering = YXBanded;
rep.nrects = nrects;
if (client->swapped) {
diff --git a/Xext/shm.c b/Xext/shm.c
index cdda09f7f..dd097e605 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -52,8 +52,7 @@ in this Software without prior written authorization from The Open Group.
#include "servermd.h"
#include "shmint.h"
#include "xace.h"
-#define _XSHM_SERVER_
-#include <X11/extensions/shmstr.h>
+#include <X11/extensions/shmproto.h>
#include <X11/Xfuncproto.h>
/* Needed for Solaris cross-zone shared memory extension */
diff --git a/Xext/shmint.h b/Xext/shmint.h
index ec1688d53..8f8a00d4f 100644
--- a/Xext/shmint.h
+++ b/Xext/shmint.h
@@ -23,13 +23,39 @@
#ifndef _SHMINT_H_
#define _SHMINT_H_
-#define _XSHM_SERVER_
-#include <X11/extensions/shmstr.h>
+#include <X11/extensions/shmproto.h>
#include "screenint.h"
#include "pixmap.h"
#include "gc.h"
+#define XSHM_PUT_IMAGE_ARGS \
+ DrawablePtr /* dst */, \
+ GCPtr /* pGC */, \
+ int /* depth */, \
+ unsigned int /* format */, \
+ int /* w */, \
+ int /* h */, \
+ int /* sx */, \
+ int /* sy */, \
+ int /* sw */, \
+ int /* sh */, \
+ int /* dx */, \
+ int /* dy */, \
+ char * /* data */
+
+#define XSHM_CREATE_PIXMAP_ARGS \
+ ScreenPtr /* pScreen */, \
+ int /* width */, \
+ int /* height */, \
+ int /* depth */, \
+ char * /* addr */
+
+typedef struct _ShmFuncs {
+ PixmapPtr (* CreatePixmap)(XSHM_CREATE_PIXMAP_ARGS);
+ void (* PutImage)(XSHM_PUT_IMAGE_ARGS);
+} ShmFuncs, *ShmFuncsPtr;
+
extern _X_EXPORT void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);
diff --git a/Xext/sync.c b/Xext/sync.c
index d7ab63cd5..667f8ab78 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -65,10 +65,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
-#define _SYNC_SERVER
-#include <X11/extensions/sync.h>
-#undef _SYNC_SERVER
-#include <X11/extensions/syncstr.h>
+#include <X11/extensions/syncproto.h>
#include "syncsrv.h"
#include <stdio.h>
@@ -965,28 +962,24 @@ SyncComputeBracketValues(SyncCounter *pCounter, Bool startOver)
pnewltval = &psci->bracket_less;
}
}
- else if ( (pTrigger->test_type == XSyncPositiveTransition &&
+ else if (pTrigger->test_type == XSyncNegativeTransition &&
ct != XSyncCounterNeverIncreases)
- ||
- (pTrigger->test_type == XSyncNegativeTransition &&
+ {
+ if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less))
+ {
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ }
+ }
+ else if (pTrigger->test_type == XSyncPositiveTransition &&
ct != XSyncCounterNeverDecreases)
- )
{
- if (XSyncValueLessThan(pCounter->value, pTrigger->test_value))
+ if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater))
{
- if (XSyncValueLessThan(pTrigger->test_value,
- psci->bracket_greater))
- {
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
- }
- else
- if (XSyncValueGreaterThan(pTrigger->test_value,
- psci->bracket_less))
- {
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
- }
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
}
}
} /* end for each trigger */
@@ -1179,7 +1172,7 @@ ProcSyncListSystemCounters(ClientPtr client)
{
char *name = SysCounterList[i]->pSysCounterInfo->name;
/* pad to 4 byte boundary */
- len += (sz_xSyncSystemCounter + strlen(name) + 3) & ~3;
+ len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
}
if (len)
@@ -1189,7 +1182,7 @@ ProcSyncListSystemCounters(ClientPtr client)
return BadAlloc;
}
- rep.length = len >> 2;
+ rep.length = bytes_to_int32(len);
if (client->swapped)
{
@@ -1223,7 +1216,7 @@ ProcSyncListSystemCounters(ClientPtr client)
pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
strncpy(pname_in_reply, psci->name, namelen);
walklist = (xSyncSystemCounter *) (((char *)walklist) +
- ((sz_xSyncSystemCounter + namelen + 3) & ~3));
+ pad_to_int32(sz_xSyncSystemCounter + namelen));
}
WriteToClient(client, sizeof(rep), (char *) &rep);
@@ -1600,7 +1593,7 @@ ProcSyncCreateAlarm(ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->id, client);
vmask = stuff->valueMask;
- len = client->req_len - (sizeof(xSyncCreateAlarmReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq));
/* the "extra" call to Ones accounts for the presence of 64 bit values */
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
return BadLength;
@@ -1681,7 +1674,7 @@ ProcSyncChangeAlarm(ClientPtr client)
return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
vmask = stuff->valueMask;
- len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
/* the "extra" call to Ones accounts for the presence of 64 bit values */
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
return BadLength;
@@ -1720,7 +1713,7 @@ ProcSyncQueryAlarm(ClientPtr client)
return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
rep.type = X_Reply;
- rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2;
+ rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
rep.sequenceNumber = client->sequence;
pTrigger = &pAlarm->trigger;
@@ -1773,6 +1766,7 @@ ProcSyncDestroyAlarm(ClientPtr client)
rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
client, DixDestroyAccess);
+ if (rc != Success)
return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
FreeResource(stuff->alarm, RT_NONE);
diff --git a/Xext/xace.c b/Xext/xace.c
index 6eaba6dbc..bf0e98fb0 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -1,6 +1,6 @@
/************************************************************
-Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
@@ -100,114 +100,104 @@ int XaceHook(int hook, ...)
switch (hook)
{
case XACE_RESOURCE_ACCESS: {
- XaceResourceAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, XID),
- va_arg(ap, RESTYPE),
- va_arg(ap, pointer),
- va_arg(ap, RESTYPE),
- va_arg(ap, pointer),
- va_arg(ap, Mask),
- Success /* default allow */
- };
+ XaceResourceAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.id = va_arg(ap, XID);
+ rec.rtype = va_arg(ap, RESTYPE);
+ rec.res = va_arg(ap, pointer);
+ rec.ptype = va_arg(ap, RESTYPE);
+ rec.parent = va_arg(ap, pointer);
+ rec.access_mode = va_arg(ap, Mask);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_DEVICE_ACCESS: {
- XaceDeviceAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, DeviceIntPtr),
- va_arg(ap, Mask),
- Success /* default allow */
- };
+ XaceDeviceAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.dev = va_arg(ap, DeviceIntPtr);
+ rec.access_mode = va_arg(ap, Mask);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_SEND_ACCESS: {
- XaceSendAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, DeviceIntPtr),
- va_arg(ap, WindowPtr),
- va_arg(ap, xEventPtr),
- va_arg(ap, int),
- Success /* default allow */
- };
+ XaceSendAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.dev = va_arg(ap, DeviceIntPtr);
+ rec.pWin = va_arg(ap, WindowPtr);
+ rec.events = va_arg(ap, xEventPtr);
+ rec.count = va_arg(ap, int);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_RECEIVE_ACCESS: {
- XaceReceiveAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, WindowPtr),
- va_arg(ap, xEventPtr),
- va_arg(ap, int),
- Success /* default allow */
- };
+ XaceReceiveAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.pWin = va_arg(ap, WindowPtr);
+ rec.events = va_arg(ap, xEventPtr);
+ rec.count = va_arg(ap, int);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_CLIENT_ACCESS: {
- XaceClientAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, ClientPtr),
- va_arg(ap, Mask),
- Success /* default allow */
- };
+ XaceClientAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.target = va_arg(ap, ClientPtr);
+ rec.access_mode = va_arg(ap, Mask);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_EXT_ACCESS: {
- XaceExtAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, ExtensionEntry*),
- DixGetAttrAccess,
- Success /* default allow */
- };
+ XaceExtAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.ext = va_arg(ap, ExtensionEntry*);
+ rec.access_mode = DixGetAttrAccess;
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_SERVER_ACCESS: {
- XaceServerAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, Mask),
- Success /* default allow */
- };
+ XaceServerAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.access_mode = va_arg(ap, Mask);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_SCREEN_ACCESS:
case XACE_SCREENSAVER_ACCESS: {
- XaceScreenAccessRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, ScreenPtr),
- va_arg(ap, Mask),
- Success /* default allow */
- };
+ XaceScreenAccessRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.screen = va_arg(ap, ScreenPtr);
+ rec.access_mode = va_arg(ap, Mask);
+ rec.status = Success; /* default allow */
calldata = &rec;
prv = &rec.status;
break;
}
case XACE_AUTH_AVAIL: {
- XaceAuthAvailRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, XID)
- };
+ XaceAuthAvailRec rec;
+ rec.client = va_arg(ap, ClientPtr);
+ rec.authId = va_arg(ap, XID);
calldata = &rec;
break;
}
case XACE_KEY_AVAIL: {
- XaceKeyAvailRec rec = {
- va_arg(ap, xEventPtr),
- va_arg(ap, DeviceIntPtr),
- va_arg(ap, int)
- };
+ XaceKeyAvailRec rec;
+ rec.event = va_arg(ap, xEventPtr);
+ rec.keybd = va_arg(ap, DeviceIntPtr);
+ rec.count = va_arg(ap, int);
calldata = &rec;
break;
}
diff --git a/Xext/xace.h b/Xext/xace.h
index 0f803f9df..6029d87d8 100644
--- a/Xext/xace.h
+++ b/Xext/xace.h
@@ -1,6 +1,6 @@
/************************************************************
-Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
diff --git a/Xext/xacestr.h b/Xext/xacestr.h
index ba115a427..84216c8c0 100644
--- a/Xext/xacestr.h
+++ b/Xext/xacestr.h
@@ -1,6 +1,6 @@
/************************************************************
-Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index aed2e4eb4..f644cb458 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -37,7 +37,7 @@ from The Open Group.
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
-#include <X11/extensions/xcmiscstr.h>
+#include <X11/extensions/xcmiscproto.h>
#include "modinit.h"
#if HAVE_STDINT_H
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 7d4c69766..aeea23313 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -72,8 +72,7 @@
#include "dixfontstr.h"
#include "extnsionst.h"
-#define _XF86BIGFONT_SERVER_
-#include <X11/extensions/xf86bigfstr.h>
+#include <X11/extensions/xf86bigfproto.h>
static void XF86BigfontResetProc(
ExtensionEntry * /* extEntry */
@@ -629,7 +628,7 @@ ProcXF86BigfontQueryFont(
return BadAlloc;
}
reply->type = X_Reply;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->sequenceNumber = client->sequence;
reply->minBounds = pFont->info.ink_minbounds;
reply->maxBounds = pFont->info.ink_maxbounds;
diff --git a/Xext/xres.c b/Xext/xres.c
index 5c04c1184..9dd08b113 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -75,7 +75,7 @@ ProcXResQueryClients (ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_clients = num_clients;
- rep.length = rep.num_clients * sz_xXResClient >> 2;
+ rep.length = bytes_to_int32(rep.num_clients * sz_xXResClient);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
@@ -144,7 +144,7 @@ ProcXResQueryClientResources (ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_types = num_types;
- rep.length = rep.num_types * sz_xXResType >> 2;
+ rep.length = bytes_to_int32(rep.num_types * sz_xXResType);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 9898b2986..b9b16b6ce 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1,6 +1,6 @@
/************************************************************
-Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
@@ -913,6 +913,10 @@ SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
security_id_t tsid;
int rc;
+ /* Don't care about the new content check */
+ if (rec->access_mode & DixPostAccess)
+ return;
+
subj = dixLookupPrivate(&rec->client->devPrivates, subjectKey);
obj = dixLookupPrivate(&pProp->devPrivates, objectKey);
@@ -1279,7 +1283,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
}
rep.type = X_Reply;
- rep.length = (len + 3) >> 2;
+ rep.length = bytes_to_int32(len);
rep.sequenceNumber = client->sequence;
rep.context_len = len;
@@ -1314,14 +1318,6 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
return BadAlloc;
}
- if (offset == CTX_DEV) {
- /* Device create context currently requires manage permission */
- rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
- if (rc != Success)
- goto out;
- privPtr = &serverClient->devPrivates;
- }
-
ptr = dixLookupPrivate(privPtr, subjectKey);
pSid = (security_id_t *)(ptr + offset);
sidput(*pSid);
@@ -1333,7 +1329,7 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
avc_context_to_sid_raw(ctx, pSid) < 0)
rc = BadValue;
}
-out:
+
xfree(ctx);
return rc;
}
@@ -1506,8 +1502,8 @@ SELinuxPopulateItem(SELinuxListItemRec *i, PrivateRec **privPtr, CARD32 id,
return BadValue;
i->id = id;
- i->octx_len = (strlen(i->octx) + 4) >> 2;
- i->dctx_len = (strlen(i->dctx) + 4) >> 2;
+ i->octx_len = bytes_to_int32(strlen(i->octx) + 1);
+ i->dctx_len = bytes_to_int32(strlen(i->dctx) + 1);
*size += i->octx_len + i->dctx_len + 3;
return Success;
diff --git a/Xext/xselinux.h b/Xext/xselinux.h
index 065ff8dd2..e99f05b09 100644
--- a/Xext/xselinux.h
+++ b/Xext/xselinux.h
@@ -1,6 +1,6 @@
/************************************************************
-Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
@@ -373,8 +373,8 @@ static struct security_class_mapping map[] = {
{ "x_device",
{ "read", /* DixReadAccess */
"write", /* DixWriteAccess */
- "", /* DixDestroyAccess */
- "", /* DixCreateAccess */
+ "destroy", /* DixDestroyAccess */
+ "create", /* DixCreateAccess */
"getattr", /* DixGetAttrAccess */
"setattr", /* DixSetAttrAccess */
"list_property", /* DixListPropAccess */
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 32abe2a81..0400062d8 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -32,6 +32,7 @@
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <X11/Xatom.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
@@ -44,19 +45,38 @@
#include "mi.h"
#include "xkbsrv.h"
#include "xkbstr.h"
-#define _XTEST_SERVER_
-#include <X11/extensions/XTest.h>
-#include <X11/extensions/xteststr.h>
+#include <X11/extensions/xtestproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exglobals.h"
#include "mipointer.h"
+#include "xserver-properties.h"
+#include "exevents.h"
#include "modinit.h"
extern int DeviceValuator;
-extern int DeviceMotionNotify;
-extern DevPrivateKey XTstDevicePrivateKey;
+
+/* XTest events are sent during request processing and may be interruped by
+ * a SIGIO. We need a separate event list to avoid events overwriting each
+ * other's memory */
+static EventListPtr xtest_evlist;
+
+/* Used to store if a device is an XTest Virtual device */
+static int XTestDevicePrivateKeyIndex;
+DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex;
+
+/**
+ * xtestpointer
+ * is the virtual pointer for XTest. It is the first slave
+ * device of the VCP.
+ * xtestkeyboard
+ * is the virtual keyboard for XTest. It is the first slave
+ * device of the VCK
+ *
+ * Neither of these devices can be deleted.
+ */
+DeviceIntPtr xtestpointer, xtestkeyboard;
#ifdef PANORAMIX
#include "panoramiX.h"
@@ -85,6 +105,8 @@ XTestExtensionInit(INITARGS)
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
NULL, StandardMinorOpcode);
+
+ xtest_evlist = InitEventList(GetMaximumEventsNum());
}
static int
@@ -158,7 +180,6 @@ ProcXTestFakeInput(ClientPtr client)
int valuators[MAX_VALUATORS] = {0};
int numValuators = 0;
int firstValuator = 0;
- EventListPtr events;
int nevents = 0;
int i;
int base = 0;
@@ -190,11 +211,34 @@ ProcXTestFakeInput(ClientPtr client)
switch (type) {
case XI_DeviceKeyPress:
case XI_DeviceKeyRelease:
+ if (!dev->key)
+ {
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ break;
case XI_DeviceButtonPress:
case XI_DeviceButtonRelease:
+ if (!dev->button)
+ {
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ break;
case XI_DeviceMotionNotify:
+ if (!dev->valuator)
+ {
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ break;
case XI_ProximityIn:
case XI_ProximityOut:
+ if (!dev->proximity)
+ {
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
break;
default:
client->errorValue = ev->u.u.type;
@@ -271,8 +315,6 @@ ProcXTestFakeInput(ClientPtr client)
} else
{
- DeviceIntPtr it;
-
if (nev != 1)
return BadLength;
switch (type)
@@ -299,14 +341,7 @@ ProcXTestFakeInput(ClientPtr client)
return BadValue;
}
- /* When faking core events through XTest, we always fake through the
- * virtual test device.
- */
- for(it = inputInfo.devices; it ; it = it->next )
- if( !IsMaster(it) && it->u.master == dev &&
- dixLookupPrivate(&it->devPrivates, XTstDevicePrivateKey ))
- break;
- dev= it;
+ dev = GetXTestDevice(dev);
}
/* If the event has a time set, wait for it to pass */
@@ -396,26 +431,25 @@ ProcXTestFakeInput(ClientPtr client)
if (screenIsSaved == SCREEN_SAVER_ON)
dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
- GetEventList(&events);
switch(type) {
case MotionNotify:
- nevents = GetPointerEvents(events, dev, type, 0, flags,
+ nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags,
firstValuator, numValuators, valuators);
break;
case ButtonPress:
case ButtonRelease:
- nevents = GetPointerEvents(events, dev, type, ev->u.u.detail,
+ nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail,
flags, firstValuator,
numValuators, valuators);
break;
case KeyPress:
case KeyRelease:
- nevents = GetKeyboardEvents(events, dev, type, ev->u.u.detail);
+ nevents = GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail);
break;
}
for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(events+i)->event, NULL);
+ mieqProcessDeviceEvent(dev, (InternalEvent*)(xtest_evlist+i)->event, NULL);
miPointerUpdateSprite(dev);
return client->noClientException;
@@ -549,3 +583,126 @@ SProcXTestDispatch (ClientPtr client)
return BadRequest;
}
}
+
+/**
+ * Allocate an virtual slave device for xtest events, this
+ * is a slave device to inputInfo master devices
+ */
+void InitXTestDevices(void)
+{
+ if(AllocXTestDevice(serverClient, "Virtual core",
+ &xtestpointer, &xtestkeyboard,
+ inputInfo.pointer, inputInfo.keyboard) != Success)
+ FatalError("Failed to allocate XTest devices");
+
+ if (ActivateDevice(xtestpointer, TRUE) != Success ||
+ ActivateDevice(xtestkeyboard, TRUE) != Success)
+ FatalError("Failed to activate XTest core devices.");
+ if (!EnableDevice(xtestpointer, TRUE) ||
+ !EnableDevice(xtestkeyboard, TRUE))
+ FatalError("Failed to enable XTest core devices.");
+
+ AttachDevice(NULL, xtestpointer, inputInfo.pointer);
+ AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard);
+}
+
+/**
+ * Don't allow changing the XTest property.
+ */
+static int
+DeviceSetXTestProperty(DeviceIntPtr dev, Atom property,
+ XIPropertyValuePtr prop, BOOL checkonly)
+{
+ if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE))
+ return BadAccess;
+
+ return Success;
+}
+
+/**
+ * Allocate a device pair that is initialised as a slave
+ * device with properties that identify the devices as belonging
+ * to XTest subsystem.
+ * This only creates the pair, Activate/Enable Device
+ * still need to be called.
+ */
+int AllocXTestDevice (ClientPtr client, char* name,
+ DeviceIntPtr* ptr, DeviceIntPtr* keybd,
+ DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
+{
+ int retval;
+ int len = strlen(name);
+ char *xtestname = xcalloc(len + 7, 1 );
+ char dummy = 1;
+
+ strncpy( xtestname, name, len);
+ strncat( xtestname, " XTEST", 6 );
+
+ retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
+ if ( retval == Success ){
+ dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)master_ptr->id);
+ dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)master_keybd->id);
+ }
+
+ xfree( xtestname );
+
+ XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
+ XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+ FALSE);
+ XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
+ XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL);
+ XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
+ XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+ FALSE);
+ XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
+ XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL);
+
+ return retval;
+}
+
+/**
+ * If master is NULL, return TRUE if the given device is an xtest device or
+ * FALSE otherwise.
+ * If master is not NULL, return TRUE if the given device is this master's
+ * xtest device.
+ */
+BOOL
+IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
+{
+ int is_XTest = FALSE;
+ int mid;
+ void *tmp; /* shut up, gcc! */
+
+ if (IsMaster(dev))
+ return is_XTest;
+
+ tmp = dixLookupPrivate(&dev->devPrivates, XTestDevicePrivateKey);
+ mid = (int)tmp;
+
+ /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest
+ * device */
+ if ((!master && mid) ||
+ (master && mid == master->id))
+ is_XTest = TRUE;
+
+ return is_XTest;
+}
+
+/**
+ * @return The X Test virtual device for the given master.
+ */
+DeviceIntPtr
+GetXTestDevice(DeviceIntPtr master)
+{
+ DeviceIntPtr it;
+
+ for (it = inputInfo.devices; it; it = it->next)
+ {
+ if (IsXTestDevice(it, master))
+ return it;
+ }
+
+ /* This only happens if master is a slave device. don't do that */
+ return NULL;
+}
+
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index fcb61e476..04cd11a3f 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -42,8 +42,7 @@ SOFTWARE.
#include <X11/extensions/Xvproto.h>
#include "xvdix.h"
#ifdef MITSHM
-#define _XSHM_SERVER_
-#include <X11/extensions/shmstr.h>
+#include <X11/extensions/shmproto.h>
#endif
#include "xvdisp.h"
@@ -423,12 +422,12 @@ ProcXvQueryAdaptors(ClientPtr client)
pa = pxvs->pAdaptors;
while (na--)
{
- totalSize += (strlen(pa->name) + 3) & ~3;
+ totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
- rep.length = totalSize >> 2;
+ rep.length = bytes_to_int32(totalSize);
_WriteQueryAdaptorsReply(client, &rep);
@@ -498,11 +497,11 @@ ProcXvQueryEncodings(ClientPtr client)
totalSize = ne * sz_xvEncodingInfo;
while (ne--)
{
- totalSize += (strlen(pe->name) + 3) & ~3;
+ totalSize += pad_to_int32(strlen(pe->name));
pe++;
}
- rep.length = totalSize >> 2;
+ rep.length = bytes_to_int32(totalSize);
_WriteQueryEncodingsReply(client, &rep);
@@ -923,7 +922,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < pPort->pAdaptor->nAttributes; i++, pAtt++)
{
- rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
+ rep.text_size += pad_to_int32(strlen(pAtt->name) + 1);
}
rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo)
@@ -939,7 +938,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
Info.flags = pAtt->flags;
Info.min = pAtt->min_value;
Info.max = pAtt->max_value;
- Info.size = (size + 3) & ~3L;
+ Info.size = pad_to_int32(size);
_WriteAttributeInfo(client, &Info);
@@ -999,7 +998,7 @@ ProcXvPutImage(ClientPtr client)
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
pPort, pImage, &width, &height, NULL, NULL);
size += sizeof(xvPutImageReq);
- size = (size + 3) >> 2;
+ size = bytes_to_int32(size);
if((width < stuff->width) || (height < stuff->height))
return BadValue;
@@ -1203,7 +1202,7 @@ ProcXvListImageFormats(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_formats = pPort->pAdaptor->nImages;
- rep.length = pPort->pAdaptor->nImages * sz_xvImageFormatInfo >> 2;
+ rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo);
_WriteListImageFormatsReply(client, &rep);
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 879a222bd..b7bb0fc1b 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -153,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num = (adaptor) ? adaptor->num_surfaces : 0;
- rep.length = rep.num * sizeof(xvmcSurfaceInfo) >> 2;
+ rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo));
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep);
@@ -519,7 +519,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if(surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
- rep.length = rep.num * sizeof(xvImageFormatInfo) >> 2;
+ rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep);
@@ -588,8 +588,8 @@ ProcXvMCGetDRInfo(ClientPtr client)
rep.major = pScreenPriv->major;
rep.minor = pScreenPriv->minor;
rep.patchLevel = pScreenPriv->patchLevel;
- rep.nameLen = (strlen(pScreenPriv->clientDriverName) + 4) >> 2;
- rep.busIDLen = (strlen(pScreenPriv->busID) + 4) >> 2;
+ rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1);
+ rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1);
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<=2;