From owner-freebsd-bugs Fri Jun 12 09:51:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA20046 for freebsd-bugs-outgoing; Fri, 12 Jun 1998 09:51:03 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA19952 for ; Fri, 12 Jun 1998 09:50:30 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id JAA20763; Fri, 12 Jun 1998 09:50:01 -0700 (PDT) Received: from alpha.xerox.com (omega.Xerox.COM [13.1.64.95]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id JAA18917 for ; Fri, 12 Jun 1998 09:46:21 -0700 (PDT) (envelope-from fenner@parc.xerox.com) Received: from mango.parc.xerox.com ([13.1.102.232]) by alpha.xerox.com with SMTP id <32525(2)>; Fri, 12 Jun 1998 09:45:48 PDT Received: (from fenner@localhost) by mango.parc.xerox.com (8.8.8/8.8.8) id JAA03090; Fri, 12 Jun 1998 09:45:20 -0700 (PDT) (envelope-from fenner) Message-Id: <199806121645.JAA03090@mango.parc.xerox.com> Date: Fri, 12 Jun 1998 09:45:20 PDT From: Bill Fenner Reply-To: fenner@parc.xerox.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/6928: syscons: MOUSE_BUTTON_EVENT uses overlapping union members Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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