Pixmap cursor bug?

mouse at mojatatu.com mouse at mojatatu.com
Tue Jan 23 19:26:39 UTC 2024


>> [...bug in some CreateCursor implementations...]
>> [test case ftp.rodents-montreal.org:/mouse/misc/cursor-bug.c]

>> I wrote patches to fix this for two server versions
(fairly old server versions, by now)
>> (though I do have low-to-negative confidence I got the code right
>> for other architectures)

> The patches sound great, please send them on.  I may not have time to
> merge them myself but I can at least get them into gitlab with some
> commentary for the next adventurous soul.

Well, that's the next step towards getting this ooooold[%] bug fixed,
seems to me!  (Ideally, something like cursor-bug.c should make it into
X's regression tests, but I don't know how much of a pipe dream that
is.)

[%] My patches below were written in 2013 and 2014.  I have code in one
program to work around this issue; that code dates back further than my
keeping of that program in a git repo, which in this case means before
2010-11-10.  My own memory, while fuzzy, says that workaround dates
back to the 1990s.  I may be able to dig up something more precise if
it matters, but I suspect it doesn't.

Here are the patches I mentioned.  In case it's necessary to satisfy
any formal requirements, I hereby release any intellectual property
rights I may have in these patches into the public domain; in
jurisdictions where that's not possible, I grant an unlimited,
royalty-free, perpetual, sublicensable license to any intellectual
property rights I may have in these patches to anyone obtaining a copy
of them.

First is the one for the server that shipped with NetBSD 5.2 on amd64:

commit c1a0482bb60f8a84e4de664e6b2d6fefeddd30b6
Author: Mouse <mouse at Rodents-Montreal.ORG>
Date:   Sat Aug 31 12:51:37 2013 -0400

    Fix the ugly-cursor-extension bug.  (Well, for amd64 at least.)
    
    This probably needs attention from someone who knows server internals
    to get it right for all bitmap bit orders and byte orders and whatnot.
    This works for the few cases I care about.

diff --git a/external/mit/xorg-server/dist/dix/dispatch.c b/external/mit/xorg-server/dist/dix/dispatch.c
index 47369a3..5a357cd 100644
--- a/external/mit/xorg-server/dist/dix/dispatch.c
+++ b/external/mit/xorg-server/dist/dix/dispatch.c
@@ -2890,9 +2890,17 @@ ProcCreateCursor (ClientPtr client)
 					 XYPixmap, 1, (pointer)srcbits);
     if ( msk == (PixmapPtr)NULL)
     {
-	unsigned char *bits = mskbits;
-	while (--n >= 0)
-	    *bits++ = ~0;
+      register int y;
+      register int x;
+      register int w;
+      w = BitmapBytePad(width);
+      for (y=height-1;y>=0;y--)
+       { for (x=(w*8)-1;x>=0;x--)
+	  { if (x < width)
+	     { mskbits[(y*w)+(x>>3)] |= 1 << (x & 7);
+	     }
+	  }
+       }
     }
     else
     {

Next is the one for NetBSD 4.0.1 on i386 (the Author: is a historical
artifact; it really should be the same as for the patch above, but I
got sloppy and didn't set things up properly before committing):

commit 0756d0e09108b9d215cfd71cf861c131826f1211
Author: Charlie <root at Sadie.Rodents-Montreal.ORG>
Date:   Sun Nov 2 14:55:37 2014 -0500

    Fix the ugly-cursor-extension bug.  (Well, for i386 at least.)
    
    This probably needs attention from someone who knows server internals
    to get it right for all bitmap bit orders and byte orders and whatnot.
    This works for the few cases I care about.

diff --git a/xfree/xc/programs/Xserver/dix/dispatch.c b/xfree/xc/programs/Xserver/dix/dispatch.c
index 92c4e9a..ee35bdd 100644
--- a/xfree/xc/programs/Xserver/dix/dispatch.c
+++ b/xfree/xc/programs/Xserver/dix/dispatch.c
@@ -3133,9 +3133,20 @@ ProcCreateCursor( client)
 					 XYPixmap, 1, (pointer)srcbits);
     if ( msk == (PixmapPtr)NULL)
     {
-	register unsigned char *bits = mskbits;
-	while (--n >= 0)
-	    *bits++ = ~0;
+	register int y;
+	register int x;
+	register int w;
+	w = BitmapBytePad(width);
+	for (y=height-1;y>=0;y--)
+	 { for (x=(w*8)-1;x>=0;x--)
+	    { if (x < width)
+	       { mskbits[(y*w)+(x>>3)] |= 1 << (x & 7);
+	       }
+	      else
+	       { mskbits[(y*w)+(x>>3)] &= ~(1 << (x & 7));
+	       }
+	    }
+	 }
     }
     else
     {

					Mouse


More information about the xorg mailing list