summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:12:42 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:14:50 -0700
commitdccb0858d71341e1258800b37d1bb78c0115838d (patch)
treee08c6018ae5af5504caf667598c71659c2c45ade /dix
parentdb69212df8a0bf09140368356d2d430c54afe346 (diff)
Core events: invert check for permission to copy key states
Always initialize to zero, and then if permission is granted, copy the current key state maps. Use memcpy instead of memmove for the copy, since we're always copying to a newly allocated event on the stack, so guaranteed not to overlap with the device map structure. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'dix')
-rw-r--r--dix/events.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/dix/events.c b/dix/events.c
index 79337490a..6e4385a16 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4512,11 +4512,12 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
if ((type == EnterNotify) && (mask & KeymapStateMask)) {
xKeymapEvent ke;
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
+ int rc;
- if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
- memset((char *) &ke.map[0], 0, 31);
- else
- memmove((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
+ memset((char *) &ke.map[0], 0, 31);
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
+ if (rc == Success)
+ memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
ke.type = KeymapNotify;
if (grab)
@@ -4617,11 +4618,12 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) {
xKeymapEvent ke;
ClientPtr client = wClient(pWin);
+ int rc;
- if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
- memset((char *) &ke.map[0], 0, 31);
- else
- memmove((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
+ memset((char *) &ke.map[0], 0, 31);
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess);
+ if (rc == Success)
+ memcpy((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
ke.type = KeymapNotify;
DeliverEventsToWindow(dev, pWin, (xEvent *) &ke, 1,