sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-10-26 22:50:19 +00:00
parent e1ec829e63
commit 68fa196282
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
30 changed files with 268 additions and 1060 deletions

View file

@ -730,7 +730,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
XIDestroyDeviceProperty(prop);
return BadAlloc;
}
new_value.size = len;
new_value.size = total_len;
new_value.type = type;
new_value.format = format;
@ -747,7 +747,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
case PropModePrepend:
new_data = new_value.data;
old_data = (void *) (((char *) new_value.data) +
(prop_value->size * size_in_bytes));
(len * size_in_bytes));
break;
}
if (new_data)

View file

@ -58,8 +58,6 @@ extern void DeviceFocusEvent(DeviceIntPtr dev,
extern void EnterWindow(DeviceIntPtr dev, WindowPtr win, int mode);
extern void LeaveWindow(DeviceIntPtr dev);
extern void CoreFocusEvent(DeviceIntPtr kbd,
int type, int mode, int detail, WindowPtr pWin);

View file

@ -410,6 +410,7 @@ typedef struct {
#endif
DevPrivateKeyRec gcPrivateKeyRec;
DevPrivateKeyRec winPrivateKeyRec;
CloseScreenProcPtr CloseScreen;
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \

View file

@ -29,6 +29,7 @@
Bool
fbCloseScreen(ScreenPtr pScreen)
{
FbScreenPrivPtr screen_priv = fbGetScreenPrivate(pScreen);
int d;
DepthPtr depths = pScreen->allowedDepths;
@ -37,9 +38,10 @@ fbCloseScreen(ScreenPtr pScreen)
free(depths[d].vids);
free(depths);
free(pScreen->visuals);
if (pScreen->devPrivate)
FreePixmap((PixmapPtr)pScreen->devPrivate);
return TRUE;
pScreen->CloseScreen = screen_priv->CloseScreen;
return pScreen->CloseScreen(pScreen);
}
Bool
@ -144,6 +146,7 @@ fbFinishScreenInit(ScreenPtr pScreen, void *pbits, int xsize, int ysize,
int dpix, int dpiy, int width, int bpp)
#endif
{
FbScreenPrivPtr screen_priv;
VisualPtr visuals;
DepthPtr depths;
int nvisuals;
@ -177,8 +180,11 @@ fbFinishScreenInit(ScreenPtr pScreen, void *pbits, int xsize, int ysize,
rootdepth, ndepths, depths,
defaultVisual, nvisuals, visuals))
return FALSE;
/* overwrite miCloseScreen with our own */
screen_priv = fbGetScreenPrivate(pScreen);
screen_priv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = fbCloseScreen;
return TRUE;
}

View file

@ -727,13 +727,6 @@ vfbCloseScreen(ScreenPtr pScreen)
pScreen->CloseScreen = pvfb->closeScreen;
/*
* fb overwrites miCloseScreen, so do this here
*/
if (pScreen->devPrivate)
(*pScreen->DestroyPixmap) (pScreen->devPrivate);
pScreen->devPrivate = NULL;
return pScreen->CloseScreen(pScreen);
}

View file

@ -335,4 +335,7 @@ union _InternalEvent {
GestureEvent gesture_event;
};
extern void
LeaveWindow(DeviceIntPtr dev);
#endif

View file

@ -397,8 +397,21 @@ miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
#ifdef PANORAMIX
&& noPanoramiXExtension
#endif
)
UpdateSpriteForScreen(pDev, pScreen);
) {
DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
/* Hack for CVE-2023-5380: if we're moving
* screens PointerWindows[] keeps referring to the
* old window. If that gets destroyed we have a UAF
* bug later. Only happens when jumping from a window
* to the root window on the other screen.
* Enter/Leave events are incorrect for that case but
* too niche to fix.
*/
LeaveWindow(pDev);
if (master)
LeaveWindow(master);
UpdateSpriteForScreen(pDev, pScreen);
}
}
/**

View file

@ -249,10 +249,10 @@ miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */
pScreen->numVisuals = numVisuals;
pScreen->visuals = visuals;
if (width) {
pScreen->CloseScreen = miCloseScreen;
#ifdef MITSHM
ShmRegisterFbFuncs(pScreen);
#endif
pScreen->CloseScreen = miCloseScreen;
}
/* else CloseScreen */
/* QueryBestSize */

View file

@ -209,7 +209,7 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
RRDestroyOutputProperty(prop);
return BadAlloc;
}
new_value.size = len;
new_value.size = total_len;
new_value.type = type;
new_value.format = format;
@ -226,7 +226,7 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
case PropModePrepend:
new_data = new_value.data;
old_data = (void *) (((char *) new_value.data) +
(prop_value->size * size_in_bytes));
(len * size_in_bytes));
break;
}
if (new_data)