mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-07 15:38:05 +02:00
Fix XAllocID race: hold the user display lock until we have a new XID.
Xlib built --without-xcb is also vulnerable to this race, and a similar fix might work there too. Also, use an XID that's truly invalid while waiting for the next XID to be requested.
This commit is contained in:
parent
54e5c0941b
commit
cc19618d2e
1 changed files with 10 additions and 1 deletions
11
src/xcb_io.c
11
src/xcb_io.c
|
|
@ -343,6 +343,10 @@ _XIDHandler(Display *dpy)
|
|||
{
|
||||
XID next = xcb_generate_id(dpy->xcb->connection);
|
||||
LockDisplay(dpy);
|
||||
#ifdef XTHREADS
|
||||
if (dpy->lock)
|
||||
(*dpy->lock->user_unlock_display)(dpy);
|
||||
#endif
|
||||
dpy->xcb->next_xid = next;
|
||||
if(dpy->flags & XlibDisplayPrivSync)
|
||||
{
|
||||
|
|
@ -357,8 +361,13 @@ _XIDHandler(Display *dpy)
|
|||
/* _XAllocID - resource ID allocation routine. */
|
||||
XID _XAllocID(Display *dpy)
|
||||
{
|
||||
const XID inval = ~0UL;
|
||||
XID ret = dpy->xcb->next_xid;
|
||||
dpy->xcb->next_xid = 0;
|
||||
#ifdef XTHREADS
|
||||
if (ret != inval && dpy->lock)
|
||||
(*dpy->lock->user_lock_display)(dpy);
|
||||
#endif
|
||||
dpy->xcb->next_xid = inval;
|
||||
|
||||
if(!(dpy->flags & XlibDisplayPrivSync))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue