From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 6 05:20:18 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7DD0816A4CF for ; Sat, 6 Mar 2004 05:20:18 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B24243D45 for ; Sat, 6 Mar 2004 05:20:18 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i26DKIbv025467 for ; Sat, 6 Mar 2004 05:20:18 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i26DKIEr025466; Sat, 6 Mar 2004 05:20:18 -0800 (PST) (envelope-from gnats) Resent-Date: Sat, 6 Mar 2004 05:20:18 -0800 (PST) Resent-Message-Id: <200403061320.i26DKIEr025466@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nicola Vitale Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B578F16A4CE for ; Sat, 6 Mar 2004 05:16:14 -0800 (PST) Received: from vsmtp3.tin.it (vsmtp3alice.tin.it [212.216.176.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id E734F43D4C for ; Sat, 6 Mar 2004 05:16:13 -0800 (PST) (envelope-from nivit@email.it) Received: from psyllobora (82.48.129.159) by vsmtp3.tin.it (7.0.019) id 402CD18F00434B9C for FreeBSD-gnats-submit@freebsd.org; Sat, 6 Mar 2004 14:16:12 +0100 Received: (qmail 330 invoked by uid 1005); 6 Mar 2004 12:36:20 -0000 Message-Id: <20040306123620.329.qmail@psyllobora> Date: 6 Mar 2004 12:36:20 -0000 From: nivit@email.it (Nicola Vitale) To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: nivit@email.it Subject: kern/63837: [USB/patch] hid_is_collection() only looks up the first item X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Nicola Vitale List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2004 13:20:18 -0000 >Number: 63837 >Category: kern >Synopsis: [USB/patch] hid_is_collection() only looks for the first item >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Mar 06 05:20:17 PST 2004 >Closed-Date: >Last-Modified: >Originator: Nicola Vitale >Release: FreeBSD 4.9-STABLE i386 >Organization: >Environment: System: FreeBSD psyllobora.domo.sva 4.9-STABLE FreeBSD 4.9-STABLE #7: Thu Feb 26 21:34:04 CET 2004 root@psyllobora.domo.sva:/usr/obj/usr/src/sys/Psyllobora i386 >Description: The function hid_is_collection, in this file: __FBSDID("$FreeBSD: src/sys/dev/usb/hid.c,v 1.11.2.7 2004/03/01 00:07:21 julian Exp $"); only looks for the first item and does not "parse" the whole of Report Descriptor, so if the usage, which you are checking, is not the first the function always returns 0. >How-To-Repeat: For example, using an USB digitizer, modify the ums(4) driver, so that it looks for HID_USAGE2(HUP_DIGITIZERS, HUP_DIGITIZER) (HUP_DIGITIZER==0x01, see HID Usages Tables), etc, etc,... >Fix: A possible solution: --- hid.c.patch begins here --- --- src/sys/dev/usb/hid.c Mon Mar 1 01:07:21 2004 +++ src/sys/dev/usb/hid.c.new Sat Mar 6 13:16:25 2004 @@ -441,15 +441,20 @@ { struct hid_data *hd; struct hid_item hi; - int err; + int err, found; hd = hid_start_parse(desc, size, hid_input); if (hd == NULL) return (0); - err = hid_get_item(hd, &hi) && - hi.kind == hid_collection && - hi.usage == usage; + found = 0; + while((err = hid_get_item(hd, &hi)) > 0) + if (hi.kind == hid_collection && hi.usage == usage) { + found = 1; + break; + } + hid_end_parse(hd); - return (err); + + return (found); } --- hid.c.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: