dix: protect event generation against single-valuator devices.
If we have a single-axis device and it sends events it should not access non-existant memory.
This commit is contained in:
		
							parent
							
								
									b25e29e801
								
							
						
					
					
						commit
						da0d3baf71
					
				| 
						 | 
					@ -576,6 +576,9 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
 | 
				
			||||||
    AxisInfoPtr axis = pDev->valuator->axes + axisNum;
 | 
					    AxisInfoPtr axis = pDev->valuator->axes + axisNum;
 | 
				
			||||||
    /* InitValuatoraAxisStruct ensures that (min < max). */
 | 
					    /* InitValuatoraAxisStruct ensures that (min < max). */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (axisNum >= pDev->valuator->numAxes)
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If a value range is defined, clip. If not, do nothing */
 | 
					    /* If a value range is defined, clip. If not, do nothing */
 | 
				
			||||||
    if (axis->max_value <= axis->min_value)
 | 
					    if (axis->max_value <= axis->min_value)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					@ -751,8 +754,16 @@ positionSprite(DeviceIntPtr dev, int *x, int *y,
 | 
				
			||||||
               ScreenPtr scr, int *screenx, int *screeny)
 | 
					               ScreenPtr scr, int *screenx, int *screeny)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /* scale x&y to screen */
 | 
					    /* scale x&y to screen */
 | 
				
			||||||
 | 
					    if (dev->valuator->numAxes > 0)
 | 
				
			||||||
        *screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL, scr->width);
 | 
					        *screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL, scr->width);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        *screenx = dev->last.valuators[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (dev->valuator->numAxes > 1 )
 | 
				
			||||||
        *screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL, scr->height);
 | 
					        *screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL, scr->height);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        *screeny = dev->last.valuators[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dev->last.valuators[0] = *screenx;
 | 
					    dev->last.valuators[0] = *screenx;
 | 
				
			||||||
    dev->last.valuators[1] = *screeny;
 | 
					    dev->last.valuators[1] = *screeny;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1006,7 +1017,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
    CARD32 ms;
 | 
					    CARD32 ms;
 | 
				
			||||||
    DeviceEvent *event;
 | 
					    DeviceEvent *event;
 | 
				
			||||||
    RawDeviceEvent    *raw;
 | 
					    RawDeviceEvent    *raw;
 | 
				
			||||||
    int x, y, /* switches between device and screen coords */
 | 
					    int x = 0, y = 0, /* switches between device and screen coords */
 | 
				
			||||||
        cx, cy; /* only screen coordinates */
 | 
					        cx, cy; /* only screen coordinates */
 | 
				
			||||||
    ScreenPtr scr = miPointerGetScreen(pDev);
 | 
					    ScreenPtr scr = miPointerGetScreen(pDev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1042,6 +1053,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
            valuators[0] = rescaleValuatorAxis(valuators[0], NULL,
 | 
					            valuators[0] = rescaleValuatorAxis(valuators[0], NULL,
 | 
				
			||||||
                    pDev->valuator->axes + 0,
 | 
					                    pDev->valuator->axes + 0,
 | 
				
			||||||
                    scr->width);
 | 
					                    scr->width);
 | 
				
			||||||
 | 
					            if (num_valuators > 1)
 | 
				
			||||||
                valuators[1] = rescaleValuatorAxis(valuators[1], NULL,
 | 
					                valuators[1] = rescaleValuatorAxis(valuators[1], NULL,
 | 
				
			||||||
                        pDev->valuator->axes + 1,
 | 
					                        pDev->valuator->axes + 1,
 | 
				
			||||||
                        scr->height);
 | 
					                        scr->height);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue