Some patches for DIX

desrt <[email protected]>
Newsgroups gmane.comp.freedesktop.xserver
Message-ID <[email protected]>
At the risk of a little bit of egg on my face (as I'm not terribly
familiar with the inner workings of DIX) I attach a couple of patches
for some bugs that I believe I've found.

First bug:  when invoking the server with display number on the command
line the display is passed to VerifyDisplayName (os/utils.c).  This
function currently allows the display to be a non-numeric string.  This
causes problems later on when trying to setup TCP listeners and UNIX
sockets.  The patch causes the X server to only allow numbers.

Second bug: mieqEnqueue keeps a record of the time of the last event in
"lastEventTime" (to avoid events being posted out of order). 
Unfortunately it never ever actually updates this value and always just
compares to the initial time recorded at initialisation.  The patch
updates the variable.

Cheers.
VerifyDisplayName-more-strict.patch (text/x-patch, 807 B)
--- xserver/os/utils.c	2004-03-03 13:03:16.117733624 -0500
+++ xserver/os/utils.c	2004-03-03 13:05:43.994252976 -0500
@@ -583,12 +583,13 @@
 static int 
 VerifyDisplayName(const char *d)
 {
-    if ( d == (char *)0 ) return( 0 );  /*  null  */
-    if ( *d == '\0' ) return( 0 );  /*  empty  */
-    if ( *d == '-' ) return( 0 );  /*  could be confused for an option  */
-    if ( *d == '.' ) return( 0 );  /*  must not equal "." or ".."  */
-    if ( strchr(d, '/') != (char *)0 ) return( 0 );  /*  very important!!!  */
-    return( 1 );
+    if ( d == NULL || *d == '\0' )     /* NULL or empty */
+	return 0;
+    if ( d[0] == '0' && d[1] != '\0' ) /* disallow names like 01 */
+	return 0;
+    if ( strspn (d, "0123456789") != strlen (d) ) /* disallow non-numbers */
+	return 0;
+    return 1;
 }
 
 /*
mieq-lastEventTime-fix.patch (text/x-patch, 414 B)
--- xserver/mi/mieq.c	2004-03-03 13:03:14.831929096 -0500
+++ xserver/mi/mieq.c	2004-03-03 13:13:07.025901928 -0500
@@ -126,6 +126,8 @@
 	miEventQueue.events[oldtail].event.u.keyButtonPointer.time =
 	    miEventQueue.lastEventTime;
     }
+    miEventQueue.lastEventTime =
+	miEventQueue.events[oldtail].event.u.keyButtonPointer.time;
     miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.