Skip to content

Fix/arbitrary failing on feature flag#1128

Draft
rajatdahal (razzat008) wants to merge 6 commits intoDevolutions:masterfrom
razzat008:fix/arbitrary_failing_on_feature_flag
Draft

Fix/arbitrary failing on feature flag#1128
rajatdahal (razzat008) wants to merge 6 commits intoDevolutions:masterfrom
razzat008:fix/arbitrary_failing_on_feature_flag

Conversation

@razzat008
Copy link

@razzat008 rajatdahal (razzat008) commented Feb 26, 2026

working on #1121

This commit adds conditional attribute, which implements the `Arbitrary`
trait when compiled with `--features arbitrary`; this is to ensure,
sucessful checks/builds for future fuzzing implementation
@razzat008
Copy link
Author

Benoît Cortier (@CBenoit)
Some structs(inside bitflags macro) needed manual implementation of the Arbitrary trait, so I'll push them too shortly.

Added conditional arbitrary for structs/enums that support it; files
related to this commit most probably won't require manual impl of the
Arbitrary trait.
Due to inter-dependency, most of the struct/enums had to be configured
…uence

The mannual impl for ChannelName follows the 8-bi null-terminated
sequence; and the mannual impl for LicenseExchangeSequence generates
arbitrary for all attributes except the license_cache
#cfg_attr for ChunkProcessor,StaticVirtualChannel and a constructor for
the StaticChannelSet(as it has TypeId which is populated by the
compiler)
@razzat008
Copy link
Author

I was not confident with some of the impls so I've added MIGHT NEED CHANGE for those parts.
Also, the StaticChannelSet had an attribute which used the TypeId which didn't implement the Arbitrary trait, so it just calls the constructor for now.

Mannual impls are done for:

  • LicenseExchangeSequence: the license_cache attribute had dyn trait
  • ChannelName: a valid null terminated sequence was required

@razzat008
Copy link
Author

The checks are passing for as of now:

cargo check -p ironrdp-connector --features arbitrary
cargo check -p ironrdp-pdu --features arbitrary

pub domain: Option<String>,
pub hardware_id: [u32; 4],
pub license_cache: Arc<dyn LicenseCache>,
pub _phantom: std::marker::PhantomData<u8>,

Choose a reason for hiding this comment

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

question: Why did you add this PhantomData?

Choose a reason for hiding this comment

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

I initially thought it was required for the dyn trait object to compile successfully, so I left it in there and forgot about it, even after the manual impl for LicenseExchangeSequence.
It compiles fine without it and isn't needed, my bad:))

Comment on lines +121 to +122
// MIGHT NEED CHANGE, currently it's not using arbitrary function
license_cache: Arc::new(NoopLicenseCache),
Copy link
Member

@CBenoit Benoît Cortier (CBenoit) Feb 27, 2026

Choose a reason for hiding this comment

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

I think this is perfectly fine as we don’t provide any LicenseCache implementation as part of this crate. Implementers wishing to fuzz using their license cache should do so on their side.

Choose a reason for hiding this comment

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

noted

Copy link
Member

@CBenoit Benoît Cortier (CBenoit) left a comment

Choose a reason for hiding this comment

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

I’m not entirely sure what the Arbitrary trait is meant to do in ironrdp-svc: we’re probably not going to deal with "arbitrary static virtual channels", so maybe a better way would be to manually implement the trait at some places more in ironrdp-connector 🤔

@razzat008
Copy link
Author

I understand, the structs in the ironrdp-svc crate were used in some other places which had to implement arbitrary, so without those checks wouldn't compile.
I will look into manual implementation for the connector.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants