Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jun 1998 09:45:20 PDT
From:      Bill Fenner <fenner@parc.xerox.com>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/6928: syscons: MOUSE_BUTTON_EVENT uses overlapping union members
Message-ID:  <199806121645.JAA03090@mango.parc.xerox.com>

next in thread | raw e-mail | index | archive | help

>Number:         6928
>Category:       kern
>Synopsis:       syscons: MOUSE_BUTTON_EVENT uses overlapping union members
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 12 09:50:01 PDT 1998
>Last-Modified:
>Originator:     Bill Fenner
>Organization:
Xerox
>Release:        FreeBSD 2.2.6-RELEASE i386
>Environment:

2.2.6-RELEASE using sysmouse.  The same code is present in -current .

>Description:

ioctl(/dev/sysmouse, CONS_MOUSECTL, &mouse) with
mouse->operation == MOUSE_BUTTON_EVENT uses values from overlapping unions:

struct mouse_data {
        int     x;
        int     y;
        int     z;
        int     buttons;
};      

struct mouse_event {
        int     id;                     /* one based */
        int     value;
};    

struct mouse_info {
        int     operation;      
        union {
                struct mouse_data data;
                struct mouse_mode mode; 
                struct mouse_event event;
        }u;
};      

mouse_info.u.event.id overlaps with mouse_info.u.data.x .  However,
the MOUSE_BUTTON_EVENT case uses u.event.id and u.event.value to
determine what button event occurred, and then uses u.data.x,
u.data.y, and u.data.z to determine if mouse motion occurred in
order to set the MOUSE_POSCHANGED flag.  Since event.id is one-based,
u.data.x will always be nonzero so MOUSE_POSCHANGED will always be
set.

>How-To-Repeat:

examine /sys/i386/isa/sysmouse.c
(while trying to figure out how to map a keyboard key into a mouse button)

>Fix:
	
Don't try to set MOUSE_POSCHANGED in the MOUSE_BUTTON_EVENT case since no
motion information is available?

--- /sys/i386/isa/syscons.c	Fri Feb 27 21:16:14 1998
+++ /tmp/syscons.c	Fri Jun 12 09:25:36 1998
@@ -1274,10 +1274,7 @@
 	        cur_console->mouse_buttons &= ~mouse->u.event.id;
 	        mouse_status.button &= ~mouse->u.event.id;
 	    }
-	    mouse_status.flags |= 
-		((mouse->u.data.x || mouse->u.data.y || mouse->u.data.z) ? 
-		    MOUSE_POSCHANGED : 0)
-		| (mouse_status.obutton ^ mouse_status.button);
+	    mouse_status.flags |= mouse_status.obutton ^ mouse_status.button;
 
 	    if (cur_console->status & MOUSE_ENABLED)
 	    	cur_console->status |= MOUSE_VISIBLE;
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806121645.JAA03090>