Skip to content

Fix minor issues and add more length checks to decoder#47

Open
313ctric wants to merge 1 commit intompowell90:mainfrom
313ctric:main
Open

Fix minor issues and add more length checks to decoder#47
313ctric wants to merge 1 commit intompowell90:mainfrom
313ctric:main

Conversation

@313ctric
Copy link

Changes:

  • Add in more references to specific spec locations in comments
  • Reorder some of the fields in the Request and Response enums to match the order in the specifications
  • Add more checks to decoders for the packet lengths
  • Add decoders/encoders for IdentifyMode, DnsHostName and DnsDomainName
  • Fix pattern matches for E1.37-7 decoders (GetCommand -> GetCommandResponse)
  • Make ProtocolVersion fields pub to allow it to be constructed in a const manner
  • Fix typos in ProductDetail and ProductCategory
  • Remove BitField and Ascii from ConvertedParameterValue (per the spec these should always have the value set to 0x0000
  • Add a type for IdentifyMode

Some of these are quite minor and also change the public API, so let me know if you'd rather not have any of them, or would like them doing differently, especially for the typos.

Also there's a new version of RDM (2025) and a new extra PIDS document (E1.37-5). I'd like to add those after this, but putting it all in one PR was far too messy.

- Fixes some minor protocol issues
- Add in decoders for IdentifyMode, DnsHostName and DnsDomainName
- Add lots of extra length checks to deserialisation
@mpowell90 mpowell90 self-requested a review March 3, 2026 10:27
@mpowell90
Copy link
Owner

Hey @313ctric, first of all, thanks the PR!

Some of these are quite minor and also change the public API, so let me know if you'd rather not have any of them, or would like them doing differently, especially for the typos.

I'm happy with breaking public API changes and typos in enum variants in minor version releases.

Also there's a new version of RDM (2025) and a new extra PIDS document (E1.37-5). I'd like to add those after this, but putting it all in one PR was far too messy.

Any further spec contributions are also massively appreciated. Would love for this crate to fully support all RDM specs and we are most of the way there.

Copy link
Owner

@mpowell90 mpowell90 left a comment

Choose a reason for hiding this comment

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

Overall a great set improvements and fixes!

Comment on lines +1907 to +1913
macro_rules! check_len {
($len:literal) => {
if bytes.len() < $len {
return Err(RdmError::InvalidMessageLength(bytes.len() as u8));
}
};
}
Copy link
Owner

Choose a reason for hiding this comment

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

i'm not a fan of defining macros in function bodies and this macro is defined twice, here and in response.rs. However I can see why you've added it - it does clean up / simplify the length validation.

Perhaps a middle ground is to extract this macro out into a utils file. we would have to change it to accept the expected and actual length due to the function variables being out of scope:

macro_rules! check_len {
    ($actual:literal, $expected:literal) => {
        if $actual < $expected {
            return Err(RdmError::InvalidMessageLength($actual as u8));
        }
    };
}

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