Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix desc_end in vendord_open() #3020

Conversation

Cynventria
Copy link
Contributor

minor fix on calculation of desc_end in vendord_open( ) for descriptor prasing

Describe the PR

fix desc_end calculation
In vendor device class, function vendord_open()

Additional context

In vendor_device.c, original code
https://github.com/hathach/tinyusb/blob/master/src/class/vendor/vendor_device.c

  const uint8_t* p_desc = tu_desc_next(desc_itf);
  const uint8_t* desc_end = p_desc + max_len;

desc_end is calaulated by p_desc + max_len which is u_desc_next(desc_itf) + max_len ,
but parameter max_len include length of desc_itf,
which make desc_end exceed the real end of descriptor by length of desc_itf

It won't cause issue since while loop stopped when all endpoints are founded
But error may occur when trying to peek descriptors after last endpoint

Since vendor_device is an ideal reference for developing new USB function
I suppose it'll be better to do the minor fix

  const uint8_t* p_desc = tu_desc_next(desc_itf);
  const uint8_t* desc_end = (uint8_t const*)desc_itf + max_len;

Encountered this when I try to check if next interface an AlternateSetting of current interface

thanks.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
minor fix on calculation of desc_end in vendord_open( ) for descriptor prasing
Copy link
Collaborator

@HiFiPhile HiFiPhile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@HiFiPhile HiFiPhile merged commit f01c4be into hathach:master Mar 11, 2025
109 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.

None yet

2 participants