Hi Hans

There is indeed a bug here, thanks for catching this! Please see my 
comments below.

> While reviewing host_endian handling in the descriptor code
> (for the BOS / ss-ep-comp desc support), I noticed something weird
> in the wince code:
>
> static int wince_get_device_descriptor(
>      struct libusb_device *device,
>      unsigned char *buffer, int *host_endian)
> {
>           struct wince_device_priv *priv = _device_priv(device);
>
>           *host_endian = 1;
>           memcpy(buffer, &priv->desc, DEVICE_DESC_LENGTH);
>           return LIBUSB_SUCCESS;
> }
>
> So the device descriptor is in host endian format, that is possible,
> but should likely be double checked.

The device descriptor is in host-endian format here, as WinCE has parsed 
the descriptor for us. We receive the descriptor from WinCE as a 
USB_DEVICE_DESCRIPTOR struct, through USBD's LPGET_DEVICE_INFO API.

>
> static int wince_get_active_config_descriptor(
>           struct libusb_device *device,
>           unsigned char *buffer, size_t len, int *host_endian)
> {
>           struct wince_device_priv *priv = _device_priv(device);
>           DWORD actualSize = len;
>           *host_endian = 1;
>           if (!UkwGetConfigDescriptor(priv->dev, UKW_ACTIVE_CONFIGURATION, 
> buffer
>                   return translate_driver_error(GetLastError());
>           }
>           return actualSize;
> }
>
> The config desc is in host_endian too? That is unlikely since it can
> contain extensions which the OS knows nothing about, so atleast those
> would need to be in raw format, as the OS would not know which
> bytes to swap. Leading to a mess of some parts host_native and
> some raw, so this is unlikely, and ...

Here, host_endian is being set incorrectly; this should indeed be set to 
0. The configuration descriptors are retrieved as raw bytes, and so are 
in bus-endian format. I'll submit a patch shortly to correct this.

>
> static int wince_get_config_descriptor(
>           struct libusb_device *device,
>           uint8_t config_index,
>           unsigned char *buffer, size_t len, int *host_endian)
> {
>           struct wince_device_priv *priv = _device_priv(device);
>           DWORD actualSize = len;
>           *host_endian = 0;
>           if (!UkwGetConfigDescriptor(priv->dev, config_index, buffer, len, 
> &actu
>                   return translate_driver_error(GetLastError());
>           }
>           return actualSize;
> }
>
> This uses the same system call, but then all of a sudden things
> are not host_endian ? Highly unlikely!

host_endian is being set correctly here. Only 
wince_get_active_config_descriptor() is setting host_endian incorrectly.

>
> Regards,
>
> Hans
>

Many thanks

Simon

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to