[PATCH xserver 09/10] Input: Set client error value for invalid mask bits
Peter Hutterer
peter.hutterer at who-t.net
Tue Dec 21 19:41:37 PST 2010
On Fri, Dec 17, 2010 at 05:13:34PM +0000, Daniel Stone wrote:
> When we send BadValue back to the client for having invalid mask bits,
> at least tell them what the (first) invalid bit was.
>
> Signed-off-by: Daniel Stone <daniel at fooishbar.org>
> ---
merged, thanks.
Cheers,
Peter
> Xi/xigrabdev.c | 2 +-
> Xi/xipassivegrab.c | 2 +-
> Xi/xiselectev.c | 15 +++++++++++++--
> include/exevents.h | 2 +-
> 4 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
> index 24ededc..0adc878 100644
> --- a/Xi/xigrabdev.c
> +++ b/Xi/xigrabdev.c
> @@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client)
> if (!IsMaster(dev))
> stuff->paired_device_mode = GrabModeAsync;
>
> - if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
> + if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
> stuff->mask_len * 4) != Success)
> return BadValue;
>
> diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
> index c5f7bf0..972988e 100644
> --- a/Xi/xipassivegrab.c
> +++ b/Xi/xipassivegrab.c
> @@ -129,7 +129,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
> return BadValue;
> }
>
> - if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
> + if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
> stuff->mask_len * 4) != Success)
> return BadValue;
>
> diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
> index 64ee173..edbd156 100644
> --- a/Xi/xiselectev.c
> +++ b/Xi/xiselectev.c
> @@ -42,14 +42,19 @@
> *
> * @return BadValue if at least one invalid bit is set or Success otherwise.
> */
> -int XICheckInvalidMaskBits(unsigned char *mask, int len)
> +int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len)
> {
> if (len >= XIMaskLen(XI2LASTEVENT))
> {
> int i;
> for (i = XI2LASTEVENT + 1; i < len * 8; i++)
> + {
> if (BitIsOn(mask, i))
> + {
> + client->errorValue = i;
> return BadValue;
> + }
> + }
> }
>
> return Success;
> @@ -126,7 +131,10 @@ ProcXISelectEvents(ClientPtr client)
> {
> unsigned char *bits = (unsigned char*)&evmask[1];
> if (BitIsOn(bits, XI_HierarchyChanged))
> + {
> + client->errorValue = XI_HierarchyChanged;
> return BadValue;
> + }
> }
>
> /* Raw events may only be selected on root windows */
> @@ -138,7 +146,10 @@ ProcXISelectEvents(ClientPtr client)
> BitIsOn(bits, XI_RawButtonPress) ||
> BitIsOn(bits, XI_RawButtonRelease) ||
> BitIsOn(bits, XI_RawMotion))
> + {
> + client->errorValue = XI_RawKeyPress;
> return BadValue;
> + }
> }
>
> if (evmask->mask_len >= 1)
> @@ -182,7 +193,7 @@ ProcXISelectEvents(ClientPtr client)
> }
> }
>
> - if (XICheckInvalidMaskBits((unsigned char*)&evmask[1],
> + if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1],
> evmask->mask_len * 4) != Success)
> return BadValue;
>
> diff --git a/include/exevents.h b/include/exevents.h
> index ae45054..32a3962 100644
> --- a/include/exevents.h
> +++ b/include/exevents.h
> @@ -327,6 +327,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
> unsigned int len, unsigned char* mask);
>
> extern int
> -XICheckInvalidMaskBits(unsigned char *mask, int len);
> +XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
>
> #endif /* EXEVENTS_H */
> --
> 1.7.2.3
More information about the xorg-devel
mailing list