From 47218a6e09549781fd61dbf5e0d3d5c81da64323 Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Wed, 4 Sep 2013 20:05:51 +0200 Subject: [PATCH] Fix bug in cursor handling. CreateCursor (Xlib call XCreatePixmapCursor) with a non-bitmap source pixmap and a None mask is supposed to error out with BadMatch, but didn't. From der Mouse , changed following comments by Alan Coopersmith . Signed-off-by: Thomas Klausner Reviewed-by: Jasper St. Pierre Signed-off-by: Peter Hutterer --- dix/dispatch.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 51d0de25f..71fda4893 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2864,18 +2864,25 @@ ProcCreateCursor(ClientPtr client) return rc; } - rc = dixLookupResourceByType((pointer *) &msk, stuff->mask, RT_PIXMAP, - client, DixReadAccess); - if (rc != Success) { - if (stuff->mask != None) { + if (src->drawable.depth != 1) + return (BadMatch); + + /* Find and validate cursor mask pixmap, if one is provided */ + if (stuff->mask != None) { + rc = dixLookupResourceByType((pointer *) &msk, stuff->mask, RT_PIXMAP, + client, DixReadAccess); + if (rc != Success) { client->errorValue = stuff->mask; return rc; } + + if (src->drawable.width != msk->drawable.width + || src->drawable.height != msk->drawable.height + || src->drawable.depth != 1 || msk->drawable.depth != 1) + return BadMatch; } - else if (src->drawable.width != msk->drawable.width - || src->drawable.height != msk->drawable.height - || src->drawable.depth != 1 || msk->drawable.depth != 1) - return BadMatch; + else + msk = NULL; width = src->drawable.width; height = src->drawable.height;