Skip to content

Comments

fix: endpoint number parsing error#224

Merged
a1ien merged 2 commits intoa1ien:masterfrom
zephyr-fun:master
Dec 29, 2025
Merged

fix: endpoint number parsing error#224
a1ien merged 2 commits intoa1ien:masterfrom
zephyr-fun:master

Conversation

@zephyr-fun
Copy link

Fixed a bug in parsing the ndpoint number from the address field in endpoint descriptor. According to the USB device specification, bits 0-3 of the address field in the endpoint descriptor represent the endpoint number. Therefore, when parsing the number from the address, it should be masked with 0xf instead of 0x7. Incorrect parsing will lead to corrupted device endpoint information.

Fan Xuan Zhe added 2 commits December 27, 2025 09:59
Fixed a bug in parsing the ndpoint number from the address field in endpoint descriptor. According to the USB device specification, bits 0-3 of the address field in the endpoint descriptor represent the endpoint number. Therefore, when parsing the number from the address, it should be masked with 0xf instead of 0x7. Incorrect parsing will lead to corrupted device endpoint information.
According to previous fix for endpoint number parsing commit, related
unit test needs to be fix as well.
@zephyr-fun
Copy link
Author

@a1ien Many thanks to the rusb library, which has been a great help in building passthrough device features in our virtual machine project. However, recently, while troubleshooting a passthrough failure, I noticed that the logic in the code attempting to obtain the endpoint number by parsing the endpoint descriptor was inconsistent with the usb device specification. This patch fixed the issue by updating the mask from 0x7 to 0xf and also updated the corresponding UT test cases. If you have time, could you please review this commit?

@a1ien
Copy link
Owner

a1ien commented Dec 29, 2025

Nice catch. Thank you.

@a1ien a1ien merged commit bb17ee3 into a1ien:master Dec 29, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants