Bug 160450 - parseDescriptorLine does not work with USB classes > 0x9
Summary: parseDescriptorLine does not work with USB classes > 0x9
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: kudzu
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-06-15 08:56 UTC by Daniel de Kok
Modified: 2014-03-17 02:54 UTC (History)
1 user (show)

Fixed In Version: 1.1.118-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-06-16 17:17:44 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Daniel de Kok 2005-06-15 08:56:39 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050517 Firefox/1.0.4 (Debian package 1.0.4-2)

Description of problem:
parseDescriptorLine() in usb.c uses atoi() to parse usb class, subclass and protocol values from descriptor lines. I have seen at least one instance where the USB class is higher than 0x9, and Kudzu will fail in detecting the proper USB class because atoi() handles decimal numbers. This may also apply to subclasses and protocol values.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. kudzu -p
2. cat /proc/bus
3. cat /proc/bus/usb/devices
  

Actual Results:  Relevant lines from "kudzu -p":

-
class: UNSPEC
bus: USB
detached: 0
driver: unknown
desc: "Ambit Microsystems Corp. USB Cable Modem"
usbclass: 0
usbsubclass: 0
usbprotocol: 0
usbbus: 1
usblevel: 1
usbport: 1
usbdev: 3
vendorId: 0bb2
deviceId: 6098
usbprod: USB Cable Modem
-

Relevant lines from /proc/bus/usb/devices:

---
T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=02(comm.) Sub=00 Prot=00 MxPS=32 #Cfgs=  1
P:  Vendor=0bb2 ProdID=6098 Rev= 1.01
S:  Product=USB Cable Modem
S:  SerialNumber=00028A714F49
C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=  0mA
I:  If#= 1 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=usbnet
E:  Ad=83(I) Atr=03(Int.) MxPS=  32 Ivl=64ms
I:  If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=usbnet
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
---

(Note the 0x0a USB class.)

Additional info:

A patch that should fix this for the USB class:

Index: usb.c
===================================================================
RCS file: /usr/local/CVS/kudzu/usb.c,v
retrieving revision 1.47
diff -b -u -r1.47 usb.c
--- usb.c       1 Dec 2004 03:39:14 -0000       1.47
+++ usb.c       15 Jun 2005 08:33:15 -0000
@@ -367,7 +367,7 @@
 
 static void parseDescriptorLine(char *line, struct usbDevice *usbdev)
 {
-       usbdev->usbclass = atoi(&line[30]);
+       usbdev->usbclass = strtol(&line[30], (char **) NULL, 16);
        usbdev->usbsubclass = atoi(&line[44]);
        usbdev->usbprotocol = atoi(&line[52]);
        usbdev->type =

Comment 1 Bill Nottingham 2005-06-16 17:17:44 UTC
Added for all three fields (since they're all hex.)

Will be in 1.1.118-1.

Comment 2 Daniel de Kok 2005-06-16 17:51:32 UTC
There is a small type on the fix (parenthesis):

diff -b -u -r1.48 usb.c
--- usb.c       16 Jun 2005 17:07:53 -0000      1.48
+++ usb.c       16 Jun 2005 17:40:35 -0000
@@ -369,7 +369,7 @@
 {
        usbdev->usbclass = strtol(&line[30], (char **)NULL, 16);
        usbdev->usbsubclass = strtol(&line[44], (char **)NULL, 16);
-       usbdev->usbprotocol = strtol(&line[52]), (char **)NULL, 16);
+       usbdev->usbprotocol = strtol(&line[52], (char **)NULL, 16);
        usbdev->type =
                usbToKudzu(usbdev->usbclass, usbdev->usbsubclass,
                           usbdev->usbprotocol);

Comment 3 Bill Nottingham 2005-06-16 17:54:37 UTC
Good catch, thanks!


Note You need to log in before you can comment on or make changes to this bug.