GetCmdVersion: Don't fall back to v0 if >0xFF#250
Merged
JohnAZoidberg merged 1 commit intomainfrom Jan 17, 2026
Merged
Conversation
v0 only supports 8 bit command IDs. I ran into an issue where truncation and then misreporting happened. I asked claude to fix it and it wanted to just try the command to see if it fails. After I said that's not a good idea, we need to figure out what's wrong, it found this issue. Signed-off-by: Daniel Schaefer <dhs@frame.work>
9f1ad76 to
163dd5c
Compare
Member
Author
|
Rewrote it again to make the code obviously safe without truncating typecasts. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the cmd_version_supported function where command IDs greater than 255 (0xFF) were being incorrectly truncated when falling back to the v0 API, which only supports 8-bit command IDs. The fix ensures that commands with IDs > 255 return false instead of being silently truncated and potentially misreported.
Changes:
- Updated the function signature to accept
u32instead ofu16for the command parameter - Added proper validation to only fall back to v0 API when the command ID fits in 8 bits
- Commands with IDs > 255 now correctly return
falseinstead of being truncated
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v0 only supports 8 bit command IDs.
I ran into an issue where truncation and then misreporting happened. I asked claude to fix it and it wanted to just try the command to see if it fails. After I said that's not a good idea, we need to figure out what's wrong, it found this issue.