Subject: pkg/37053: libusb has wrong return size for usb_control_msg
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <cyber@netbsd.org>
List: pkgsrc-bugs
Date: 10/02/2007 09:50:00
>Number:         37053
>Category:       pkg
>Synopsis:       libusb has wrong return size for usb_control_msg
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 02 09:50:00 +0000 2007
>Originator:     Erik Berls
>Release:        4.99.16
>Organization:
TNF
>Environment:
NetBSD dev0 4.99.16 NetBSD 4.99.16 (GENERIC.MP) #0: Fri Apr  6 12:32:19 PDT 2007  cyber@jonestown.local:/image/NetBSD/src/sys/arch/amd64/compile/obj/GENERIC.MP amd64

>Description:
Trying to build a program that uses libusb, usbtenki (www.ralphnet.net/en).

The program executes its own xor checksum of the returned data based on the specified return length.

It was failing the checksums, traced down to return the wrong length.
>How-To-Repeat:
1 Install libusb
2 Build usbtenki
Try to run usbtenkiget -l and notice it errors out with a checksum error.

The issue manifested itself both on a 4.99.16 amd64 box, and a 4.0_beta2 i386 box.

>Fix:
diff -r1.1 patch-ad
147a148,156
> @@ -477,7 +482,7 @@ int usb_control_msg(usb_dev_handle *dev,
>      USB_ERROR_STR(-errno, "error sending control message: %s",
>                    strerror(errno));
> 
> -  return UGETW(req.ucr_request.wLength);
> +  return req.ucr_actlen;
>  }
> 
>  int usb_os_find_busses(struct usb_bus **busses)

This fix has been tested on an amd64 box running 4.99.16.


This is the only installed use of libusb that I've attempted to use.  This needs confirmation from another user.