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>
This commit is contained in:
		
							parent
							
								
									db69212df8
								
							
						
					
					
						commit
						dccb0858d7
					
				
							
								
								
									
										18
									
								
								dix/events.c
								
								
								
								
							
							
						
						
									
										18
									
								
								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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue