179 Commits

Author SHA1 Message Date
akallabeth
a2585fd446 Fixed missing WINAPI for callback function declarations
(cherry picked from commit 3aca661f0e6adcbdace994fc2a554e55b4f58f86)
2022-05-25 10:31:09 +02:00
Alexandru Bagu
ce8616c0dc Urbrdc fix (#7417)
* fix libusb libusb_device usage (manually unref required usb devices, versus freeing all when we still hold references to the ones we want)
* disabled detach_kernel_driver & attach_kernel_driver on win32 since libusb does not support them
* fixed libusb async event handling

* add log for transfer request error

* Update libusb_udevice.c

* refactor code
2022-04-06 17:01:17 +02:00
Armin Novak
7f05f1a62a Fix data write on usb channel 2021-09-01 08:53:54 +02:00
akallabeth
7beda29158 Fixed CodeQL warnings
(cherry picked from commit 95a9e60827c91cb9b924d7ce3c220c30bd36907d)
2021-03-12 12:41:44 +01:00
akallabeth
fb213a2336 Fixed possible out of bound access in usb channel.
(cherry picked from commit 2e5280feecc3cd692f9930f9b7ed26129423a1a1)
2021-02-25 09:51:41 +01:00
akallabeth
031eb5f9aa Fixed short length for usb io control return.
(cherry picked from commit 6f00308db78f27d6daee9a85ff3baec7cd8e8443)
2020-12-01 15:10:23 +01:00
Armin Novak
b989149460 Manually free up libusb transfer data to avoid double free
(cherry picked from commit 6ce051759306219c49d4fb39a2bd9cc94c2c5afc)
2020-12-01 15:10:23 +01:00
akallabeth
f2321b8482 Fixed missing async user data extraction from libusb transfer
(cherry picked from commit 786f6bbfe8ac63eb2e069a7b83b0a49b2a9a664b)
2020-12-01 15:10:23 +01:00
Armin Novak
270e741d46 Fixed urbdrc server notification of channel close
There was a recursion issue with usb device channel closing and
local redirected device removal.
If the local redirected device is removed due to hotplug events,
the device channel needs to be closed, which in turn checks if
the local device list contains the device. Ensure that the
channel close code is only executed when not called from the
channel side.

(cherry picked from commit 93ee13245ce7fe78ffbc9694bfac3da30844296a)
2020-12-01 15:10:23 +01:00
akallabeth
5572eedc57 Removed channel close in USB channel done after channel is freed
(cherry picked from commit dbeaa614d6e369d3809e04be24f1d6b98e3d9e50)
2020-12-01 15:10:23 +01:00
akallabeth
f8445d3d94 Fixed access to user_data after free
(cherry picked from commit 8c859575cfb0fc9e35d7b211993174af444ff780)
2020-12-01 15:10:23 +01:00
akallabeth
2d5c08a837 Fixed invalid buffer length and duplicated write function.
(cherry picked from commit 54c92e78e6031d1e075625699e2d677af583716a)
2020-12-01 15:10:23 +01:00
akallabeth
ac4fd109a3 Fixed urbdrc arraylist locking
(cherry picked from commit e7533130a6bf08959670264e797487b00305e9f7)
2020-12-01 15:10:23 +01:00
Armin Novak
20502ac585 Unified streamID read/write
(cherry picked from commit 28bc636d5377b01936e161af9e94438a7e592f1d)
2020-12-01 15:10:23 +01:00
Armin Novak
8be4d1e09b Replace wHashTable with wArrayList in USB channel
The streamID is not guaranteed to be uniqe, so add all transfers
to a list and remove by checking pointers instead of the streamID

(cherry picked from commit 3ebc71abf3709871ca1609b9c99b7d234000da4a)
2020-12-01 15:10:23 +01:00
Armin Novak
7469f53c0d Added return checks for HashTable_Add
(cherry picked from commit ea8f93441d523e103746dfeceab98420c05e0bac)
2020-12-01 15:10:23 +01:00
Armin Novak
cbd7964468 Added duplicate initialization check for plugins.
(cherry picked from commit 75aab487e242f347868bd6c2ad5872d25a7c2c9a)
2020-12-01 15:10:23 +01:00
Armin Novak
e805752c4e Fixed compilation warnings.
(cherry picked from commit 57b405ca265966fd3790cb3f30d0b0c073268e7c)
2020-12-01 15:10:23 +01:00
Armin Novak
3cdfe18da9 Fixed urbdrc device path
(cherry picked from commit 63747000982f70bc169ff037bccb1bbcfd697747)
2020-07-07 10:44:12 +02:00
Armin Novak
28d878681d Fixed bDeviceClass check in udev_init
Use the proper constant  0xef (Miscellaneous) instead of
0xfe (Application Specific)
See https://www.usb.org/defined-class-codes

(cherry picked from commit b97cb4c95dd085142cadf1645505264632d1af21)
2020-07-07 10:44:12 +02:00
akallabeth
252c793c01 Replaced malloc in urbdrc channel
(cherry picked from commit 3ae6feeebe8638c3bea76fd270f3fd46ee768ff2)
2020-07-07 10:44:12 +02:00
akallabeth
059c4ed46d Fixed discrepancy in string descriptor default
(cherry picked from commit 747513d901ae50c8223a5ddd5b447436bb782a66)
2020-07-07 10:44:12 +02:00
akallabeth
effbc11867 Replaced memset in urbdrc
(cherry picked from commit e84c3829bf942b28cd6ef4d7cff4d5f8cca8a5f8)
2020-07-07 10:44:12 +02:00
akallabeth
7f8d7762e6 Unified logging for urbdrc libusb wrapper
(cherry picked from commit a81001c3a33818561bf0e6193e219b1b3245391d)
2020-07-07 10:44:12 +02:00
akallabeth
32004a50fe Initialize variable in func_instance_id_generate
(cherry picked from commit a4a4992750085367e52623209c94ed3f1c66b25b)
2020-07-07 10:44:12 +02:00
akallabeth
e1cacc0762 Improved error log for string descriptor read issues
(cherry picked from commit dd2589cebcac5b39c6af9bbe9f444f6451e9ad4b)
2020-07-07 10:44:12 +02:00
akallabeth
40a29037df Reverted check for short usb descriptor
(cherry picked from commit 6ba67a07beeb44878912851cf6ed6c6bf7443e09)
2020-07-07 10:44:11 +02:00
akallabeth
de5c013e37 Added compile time urbdrc debug option
(cherry picked from commit 5244efadcfb158c813d79b8e8c068fc33198f79b)
2020-07-07 10:44:11 +02:00
akallabeth
f621d2efea Dump USB channel data with log-level trace
(cherry picked from commit e32ba76deb8e16834a5bb0d099cc08d1ed44c04d)
2020-07-07 10:44:11 +02:00
Armin Novak
b300c8a738 Do not remove transfer data on usb cancel transfer
(cherry picked from commit a5e2d62e48619d5502f5334d431ee7d66ae9e4aa)
2020-06-16 11:20:18 +02:00
Armin Novak
fd42acc594 Fixed double free in urb_isoch_transfer_cb
(cherry picked from commit ef4de12887486857f7eec37ef93df692b2ecedf0)
2020-06-16 11:20:18 +02:00
Florian Staudacher
5491795588 report only actual bytes received, not allocated buffer size (interrupt produces data, timeout doesn't)
(cherry picked from commit 2e4f27ac9f7bcecb3c3f453341818e538386207f)
2020-06-16 09:07:16 +02:00
Florian Staudacher
f681d2450f only call 'libusb_set_interface_alt_setting' when value is changed
(cherry picked from commit ea8c922355c48b6a18900aa543e716b6ae1cd08e)
2020-06-16 09:06:45 +02:00
akallabeth
5a1167f7e3 Fixed #6197: NULL check in urbdrc
(cherry picked from commit fb3a0e6b5ae3b4e6523509a0ec0c522425968989)
2020-05-20 15:41:24 +02:00
akallabeth
3fe4650b2c Fixed DestroyListener arguments and call order
(cherry picked from commit 0e08727d4ecff2777884a23bc33961f63d52465e)
2020-05-18 16:41:20 +02:00
akallabeth
47b4867729 Destroy channel listeners on terminate
(cherry picked from commit 2f5e5359f60c26a2de244cd6d9f7957b039cd121)
2020-05-18 16:40:52 +02:00
akallabeth
eee9dead2d Fixed compiler warnings for usb channel 2020-05-08 11:06:02 +02:00
akallabeth
e928888dab Fixed various input buffer length checks in URBDRC
Thanks to hac425 CVE-2020-11039
2020-05-08 11:06:02 +02:00
akallabeth
af2ce439e1 Fixed int overflow in msusb_mspipes_read
Thanks to hac425
2020-05-08 11:06:02 +02:00
akallabeth
55f18cb8a5 Fix oob read in msusb_msconfig_read 2020-05-05 07:46:10 +02:00
Lukas Fink
6425313776 Fixes null dereference bug
Avoids a null function pointer dereference that happened, when
freerdp_urbdrc_client_subsystem_entry failed before invoking
udevman_load_interface.
2020-05-05 07:46:09 +02:00
Lukas Fink
aae9640beb Implemented udevman->hotplug_vid_pids as wArrayList 2020-05-05 07:46:09 +02:00
Lukas Fink
c668d66e88 Added ability to add usb devs via id and addr simultaneously
It is now possible to add usb devices both via vid+pid and via bus+addr
at the same time. To do this, the ids are directly
given to the corresponding command line options:
/usb🆔<vid+pids>,addr:<bus+addrs>
The dev option still works like before: /usb:id,dev:<vid+pids> or
/usb:addr,dev:<bus+addrs>
2020-05-05 07:46:09 +02:00
Lukas Fink
efb929644e Added hotplug to /usb:id,dev option
Devices specified with the /usb:id,dev command line option are now
detected by the hotplug callback.
2020-05-05 07:46:09 +02:00
Lukas Fink
2e86e36200 Fixed /usb:dev command line option
The /usb:dev command line option failed silently, because it tried to add the
devices before urbdrc gets initialized. This commit adds a new function
to udevman, that gets called when the urbdrc addin is initialized.
Registering of the given devices is now performed there.
2020-05-05 07:46:09 +02:00
akallabeth
5587bc6fc3 Removed casts in udevman_parse_device_id_addr 2020-04-28 14:03:19 +02:00
Lukas Fink
af6aa50020 Refactored parsing of usb dev: command line option
Refactored urbdrc_udevman_register_devices with its helper functions,
because the old implementation was a bit quirky. Removed a unsafe
strcpy, that led to a buffer overflow when given misonstructed command
line options. Doing something like "/usb:id,dev🔢1234##abcd:abcd"
won't work anymore, too.
2020-04-28 14:03:19 +02:00
jacobopantoja
9c79bc29f6 Restrict USBDK to Windows builds
This commit restricts ebdaea6f3b5e410b9a3380368d6023c52bed67cc to just Win32 builds
2020-04-28 14:03:19 +02:00
akallabeth
aa39e08c29 Fixed URBDRC DEVICE_ADD_FLAG definitions 2020-04-10 14:16:19 +02:00
akallabeth
42d40261c5 Fixed return type for subsystem entry 2020-04-10 14:11:15 +02:00