Revert back my change as its broken.

I will take some rest as obviously I should not allwed to commit anything rigth now.
Sorry guys.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42908 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2011-10-25 06:46:40 +00:00
parent cc6dd72fbb
commit 427e96598c

View File

@ -545,31 +545,21 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
return B_BUFFER_OVERFLOW; return B_BUFFER_OVERFLOW;
size_t actualLength = 0; size_t actualLength = 0;
uint8 firstBytes[4]; uint8 firstTwoBytes[2];
size_t bytesNeeded =
command->descriptor.type == USB_DESCRIPTOR_CONFIGURATION ?
4 : 2;
if (gUSBModule->get_descriptor(device->device, if (gUSBModule->get_descriptor(device->device,
command->descriptor.type, command->descriptor.index, command->descriptor.type, command->descriptor.index,
command->descriptor.language_id, firstBytes, bytesNeeded, command->descriptor.language_id, firstTwoBytes, 2,
&actualLength) < B_OK &actualLength) < B_OK
|| actualLength != bytesNeeded || actualLength != 2
|| firstBytes[1] != command->descriptor.type) { || firstTwoBytes[1] != command->descriptor.type) {
command->descriptor.status = B_USB_RAW_STATUS_ABORTED; command->descriptor.status = B_USB_RAW_STATUS_ABORTED;
command->descriptor.length = 0; command->descriptor.length = 0;
return B_OK; return B_OK;
} }
uint8 descriptorLength = firstBytes[0]; uint8 descriptorLength = MIN(firstTwoBytes[0],
if (command->descriptor.type == USB_DESCRIPTOR_CONFIGURATION) { command->descriptor.length);
// configuration complete descriptor total length is
// bigger than just its header size
descriptorLength =
((usb_configuration_descriptor*)firstBytes)->total_length;
}
descriptorLength = MIN(descriptorLength, command->descriptor.length);
uint8 *descriptorBuffer = (uint8 *)malloc(descriptorLength); uint8 *descriptorBuffer = (uint8 *)malloc(descriptorLength);
if (descriptorBuffer == NULL) { if (descriptorBuffer == NULL) {
command->descriptor.status = B_USB_RAW_STATUS_ABORTED; command->descriptor.status = B_USB_RAW_STATUS_ABORTED;