[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#285807: MiscPassMessage() broken



On Fri, Mar 25, 2005 at 05:07:55PM -0500, Branden Robinson wrote:
> I'm attaching a patch, based on freedesktop.org CVS (xorg module).

It would, of course, be helpful if I had actually attached the patch.

Doing so now.

-- 
G. Branden Robinson                |     Wanton killing of innocent
Debian GNU/Linux                   |     civilians is terrorism, not a war
branden@debian.org                 |     against terrorism.
http://people.debian.org/~branden/ |     -- Noam Chomsky
Index: xc/include/extensions/xf86mscstr.h
===================================================================
RCS file: /cvs/xorg/xc/include/extensions/xf86mscstr.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xc/include/extensions/xf86mscstr.h	23 Apr 2004 18:43:06 -0000	1.2
+++ xc/include/extensions/xf86mscstr.h	15 Dec 2004 00:34:34 -0000	1.3
@@ -14,7 +14,7 @@
 #define XF86MISCNAME		"XFree86-Misc"
 
 #define XF86MISC_MAJOR_VERSION	0	/* current version numbers */
-#define XF86MISC_MINOR_VERSION	8
+#define XF86MISC_MINOR_VERSION	9
 
 typedef struct _XF86MiscQueryVersion {
     CARD8	reqType;		/* always XF86MiscReqCode */
--- xc/programs/Xserver/Xext/xf86misc.c	2004-07-09 00:08:16.000000000 -0500
+++ xc/programs/Xserver/Xext/xf86misc.c	2005-02-27 23:32:26.000000000 -0500
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/xf86misc.c,v 3.38 2003/04/03 16:15:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/xf86misc.c,v 3.41 2003/11/17 22:20:27 dawes Exp $ */
 
 /*
  * Copyright (c) 1995, 1996  The XFree86 Project, Inc
@@ -54,9 +54,7 @@
 #define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr)
 
 static void XF86MiscResetProc(
-#if NeedFunctionPrototypes
     ExtensionEntry* /* extEntry */
-#endif
 );
 
 static void
@@ -104,7 +102,9 @@
 static DISPATCH_PROC(SProcXF86MiscSetSaver);
 #endif
 
+#if 0
 static unsigned char XF86MiscReqCode = 0;
+#endif
 
 #ifdef DEBUG
 # define DEBUG_P(x) ErrorF(x"\n");
@@ -150,7 +150,9 @@
 				SProcXF86MiscDispatch,
 				XF86MiscResetProc,
 				StandardMinorOpcode))) {
+#if 0
 	XF86MiscReqCode = (unsigned char)extEntry->base;
+#endif
 	miscErrorBase = extEntry->errorBase;
     }
 }
@@ -356,14 +358,13 @@
     
     if (xf86GetVerbosity() > 1) {
 	ErrorF("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n",
-		stuff->mousetype, stuff->baudrate,
-		stuff->samplerate, stuff->chordmiddle);
-	ErrorF("                   em3but: %d em3tim: %d res: %d flags: %d\n",
-		stuff->emulate3buttons, stuff->emulate3timeout,
-		stuff->resolution, stuff->flags);
+		(int)stuff->mousetype, (int)stuff->baudrate,
+		(int)stuff->samplerate, stuff->chordmiddle);
+	ErrorF("                   em3but: %d em3tim: %d res: %d flags: %ld\n",
+		stuff->emulate3buttons, (int)stuff->emulate3timeout,
+		(int)stuff->resolution, (unsigned long)stuff->flags);
     }
 
-    
     if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0)
 	return BadAlloc;
 
@@ -429,8 +430,8 @@
 
     if (xf86GetVerbosity() > 1)
 	ErrorF("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n",
-		stuff->kbdtype, stuff->rate,
-		stuff->delay, stuff->servnumlock);
+		(int)stuff->kbdtype, (int)stuff->rate,
+		(int)stuff->delay, stuff->servnumlock);
 
     if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0)
 	return BadAlloc;
@@ -581,20 +582,29 @@
 	strncpy(msgtype,(char*)(&stuff[1]),stuff->typelen);
     } else return BadValue;
     if (stuff->vallen) {
-	if (!(msgval = xalloc(stuff->vallen)))
+	if (!(msgval = xalloc(stuff->vallen))) {
+	    xfree(msgtype);
 	    return BadAlloc;
-	strncpy(msgval,(char*)(&stuff[1] + ((stuff->typelen + 3) & ~3)),
+	}
+	strncpy(msgval,(char*)((char*)&stuff[1] + ((stuff->typelen + 3) & ~3)),
 			stuff->vallen);
-    } else return BadValue;
+    } else {
+	xfree(msgtype);
+	return BadValue;
+    }
 
-    if ((retval= MiscExtPassMessage(stuff->screen,msgtype,msgval,&retstr)) != 0)
+    if ((retval = MiscExtPassMessage(stuff->screen,msgtype,msgval,&retstr)) != 0) {
+	xfree(msgtype);
+	xfree(msgval);
 	return retval;
+    }
 
     rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
     rep.mesglen = (retstr? strlen(retstr): 0);
     rep.length = (SIZEOF(xXF86MiscPassMessageReply) - SIZEOF(xGenericReply) +
 		  ((rep.mesglen + 3) & ~3)) >> 2;
+    rep.status = 0;
     
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
@@ -606,6 +616,9 @@
     if (rep.mesglen)
         WriteToClient(client, rep.mesglen, (char *)retstr);
 
+    xfree(msgtype);
+    xfree(msgval);
+    
     return (client->noClientException);
 }
 

Attachment: signature.asc
Description: Digital signature


Reply to: