mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-26 19:04:50 +00:00
Xi: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -78,12 +78,7 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||
X_REQUEST_HEAD_AT_LEAST(xChangeDeviceControlReq);
|
||||
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
|
||||
X_REQUEST_FIELD_CARD16(control);
|
||||
|
||||
if (client->swapped) {
|
||||
xDeviceCtl *ctl = (xDeviceCtl *) &stuff[1];
|
||||
swaps(&ctl->control);
|
||||
swaps(&ctl->length);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_2((xDeviceCtl*)&stuff[1], control, length);
|
||||
|
||||
unsigned len;
|
||||
int i, status, ret = BadValue;
|
||||
|
||||
48
Xi/chgfctl.c
48
Xi/chgfctl.c
@@ -76,13 +76,8 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
|
||||
int t;
|
||||
int key = DO_ALL;
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&f->length);
|
||||
swaps(&f->pitch);
|
||||
swaps(&f->duration);
|
||||
swapl(&f->led_mask);
|
||||
swapl(&f->led_values);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_3(f, length, pitch, duration);
|
||||
CLIENT_STRUCT_CARD32_2(f, led_mask, led_values);
|
||||
|
||||
kctrl = k->ctrl;
|
||||
if (mask & DvKeyClickPercent) {
|
||||
@@ -193,12 +188,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
|
||||
{
|
||||
PtrCtrl pctrl; /* might get BadValue part way through */
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&f->length);
|
||||
swaps(&f->num);
|
||||
swaps(&f->denom);
|
||||
swaps(&f->thresh);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_4(f, length, num, denom, thresh);
|
||||
|
||||
pctrl = p->ctrl;
|
||||
if (mask & DvAccelNum) {
|
||||
@@ -259,10 +249,8 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
|
||||
long unsigned int mask, IntegerFeedbackPtr i,
|
||||
xIntegerFeedbackCtl * f)
|
||||
{
|
||||
if (client->swapped) {
|
||||
swaps(&f->length);
|
||||
swapl(&f->int_to_display);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(f, length);
|
||||
CLIENT_STRUCT_CARD32_1(f, int_to_display);
|
||||
|
||||
i->ctrl.integer_displayed = f->int_to_display;
|
||||
(*i->CtrlProc) (dev, &i->ctrl);
|
||||
@@ -284,10 +272,9 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
|
||||
KeySym *syms, *sup_syms;
|
||||
|
||||
syms = (KeySym *) (f + 1);
|
||||
if (client->swapped) {
|
||||
swaps(&f->length); /* swapped num_keysyms in calling proc */
|
||||
SwapLongs((CARD32 *) syms, f->num_keysyms);
|
||||
}
|
||||
|
||||
CLIENT_STRUCT_CARD16_1(f, length); /* swapped num_keysyms in calling proc */
|
||||
REQUEST_BUF_CARD32((CARD32 *) syms, f->num_keysyms);
|
||||
|
||||
if (f->num_keysyms > s->ctrl.max_symbols)
|
||||
return BadValue;
|
||||
@@ -322,11 +309,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
|
||||
int t;
|
||||
BellCtrl bctrl; /* might get BadValue part way through */
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&f->length);
|
||||
swaps(&f->pitch);
|
||||
swaps(&f->duration);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_3(f, length, pitch, duration);
|
||||
|
||||
bctrl = b->ctrl;
|
||||
if (mask & DvPercent) {
|
||||
@@ -378,11 +361,8 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
|
||||
{
|
||||
LedCtrl lctrl; /* might get BadValue part way through */
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&f->length);
|
||||
swapl(&f->led_values);
|
||||
swapl(&f->led_mask);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(f, length);
|
||||
CLIENT_STRUCT_CARD32_2(f, led_values, led_mask);
|
||||
|
||||
f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
|
||||
f->led_values &= l->ctrl.led_mask; /* set only supported leds */
|
||||
@@ -450,11 +430,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
|
||||
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeFeedbackControlReq,
|
||||
sizeof(xStringFeedbackCtl));
|
||||
f = ((xStringFeedbackCtl *) &stuff[1]);
|
||||
if (client->swapped) {
|
||||
if (len < bytes_to_int32(sizeof(xStringFeedbackCtl)))
|
||||
return BadLength;
|
||||
swaps(&f->num_keysyms);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(f, num_keysyms);
|
||||
if (len !=
|
||||
(bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
|
||||
return BadLength;
|
||||
|
||||
@@ -56,6 +56,7 @@ SOFTWARE.
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/request_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "dix/request_priv.h"
|
||||
#include "dix/rpcbuf_priv.h"
|
||||
|
||||
@@ -79,8 +79,7 @@ ProcXSetDeviceFocus(ClientPtr client)
|
||||
|
||||
int ret;
|
||||
DeviceIntPtr dev;
|
||||
|
||||
ret = dixLookupDevice(&dev, stuff->device, client, DixSetFocusAccess);
|
||||
int ret = dixLookupDevice(&dev, stuff->device, client, DixSetFocusAccess);
|
||||
if (ret != Success)
|
||||
return ret;
|
||||
if (!dev->focus)
|
||||
|
||||
@@ -859,30 +859,25 @@ ProcXIBarrierReleasePointer(ClientPtr client)
|
||||
|
||||
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
|
||||
return BadLength;
|
||||
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
|
||||
|
||||
if (client->swapped) {
|
||||
xXIBarrierReleasePointerInfo *info = (xXIBarrierReleasePointerInfo*) &stuff[1];
|
||||
for (int i = 0; i < stuff->num_barriers; i++, info++) {
|
||||
swaps(&info->deviceid);
|
||||
swapl(&info->barrier);
|
||||
swapl(&info->eventid);
|
||||
}
|
||||
}
|
||||
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
|
||||
|
||||
int i;
|
||||
int err;
|
||||
struct PointerBarrierClient *barrier;
|
||||
struct PointerBarrier *b;
|
||||
xXIBarrierReleasePointerInfo *info;
|
||||
|
||||
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
|
||||
xXIBarrierReleasePointerInfo *info = (xXIBarrierReleasePointerInfo*) &stuff[1];
|
||||
|
||||
for (i = 0; i < stuff->num_barriers; i++, info++) {
|
||||
struct PointerBarrierDevice *pbd;
|
||||
DeviceIntPtr dev;
|
||||
CARD32 barrier_id, event_id;
|
||||
_X_UNUSED CARD32 device_id;
|
||||
|
||||
CLIENT_STRUCT_CARD16_1(info, deviceid);
|
||||
CLIENT_STRUCT_CARD32_2(info, barrier, eventid);
|
||||
|
||||
barrier_id = info->barrier;
|
||||
event_id = info->eventid;
|
||||
|
||||
|
||||
@@ -124,13 +124,6 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
|
||||
free(ev);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure allows a client to change the device hierarchy through
|
||||
* adding new master devices, removing them, etc.
|
||||
*
|
||||
*/
|
||||
|
||||
static int
|
||||
add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
|
||||
{
|
||||
@@ -452,10 +445,7 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&any->type);
|
||||
swaps(&any->length);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_2(any, type, length);
|
||||
|
||||
if (len < ((size_t)any->length << 2))
|
||||
return BadLength;
|
||||
@@ -479,8 +469,7 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
if (client->swapped)
|
||||
swaps(&c->name_len);
|
||||
CLIENT_STRUCT_CARD16_1(c, name_len);
|
||||
|
||||
if (c->name_len > (len - sizeof(xXIAddMasterInfo))) {
|
||||
rc = BadLength;
|
||||
|
||||
@@ -1011,6 +1011,15 @@ ProcXIListProperties(ClientPtr client)
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
|
||||
Atom *atoms;
|
||||
int natoms;
|
||||
DeviceIntPtr dev;
|
||||
int rc = Success;
|
||||
|
||||
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
|
||||
size_t natoms = 0;
|
||||
int rc = _writeDevProps(&rpcbuf, stuff->deviceid, client, &natoms);
|
||||
if (rc != Success)
|
||||
|
||||
@@ -57,6 +57,8 @@ int
|
||||
ProcXIQueryVersion(ClientPtr client)
|
||||
{
|
||||
X_REQUEST_HEAD_AT_LEAST(xXIQueryVersionReq);
|
||||
X_REQUEST_FIELD_CARD16(major_version);
|
||||
X_REQUEST_FIELD_CARD16(minor_version);
|
||||
|
||||
int major, minor;
|
||||
|
||||
|
||||
@@ -141,6 +141,23 @@ ProcXISelectEvents(ClientPtr client)
|
||||
if (stuff->num_masks == 0)
|
||||
return BadValue;
|
||||
|
||||
if (client->swapped) {
|
||||
int len = stuff->length - bytes_to_int32(sizeof(xXISelectEventsReq));
|
||||
xXIEventMask *evmask = (xXIEventMask *) &stuff[1];
|
||||
for (int i = 0; i < stuff->num_masks; i++) {
|
||||
if (len < bytes_to_int32(sizeof(xXIEventMask)))
|
||||
return BadLength;
|
||||
len -= bytes_to_int32(sizeof(xXIEventMask));
|
||||
swaps(&evmask->deviceid);
|
||||
swaps(&evmask->mask_len);
|
||||
if (len < evmask->mask_len)
|
||||
return BadLength;
|
||||
len -= evmask->mask_len;
|
||||
evmask =
|
||||
(xXIEventMask *) (((char *) &evmask[1]) + evmask->mask_len * 4);
|
||||
}
|
||||
}
|
||||
|
||||
WindowPtr win;
|
||||
int rc = dixLookupWindow(&win, stuff->win, client, DixReceiveAccess);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user