diff options
author | Jamey Sharp <jamey@minilop.net> | 2008-03-23 16:33:50 -0700 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2008-11-04 08:54:01 -0800 |
commit | cc19618d2eb3ed92a0b574aee26a7da8b4aed5d2 (patch) | |
tree | bfaeb685d72e94f2e6f0ebb301dca59c29414f27 | |
parent | 54e5c0941b0ded1628d559a9f0a3451ea96c299b (diff) |
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.
-rw-r--r-- | src/xcb_io.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/xcb_io.c b/src/xcb_io.c index 830ddb9f..d0abf4c6 100644 --- a/src/xcb_io.c +++ b/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)) { |