diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-02-20 12:31:45 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-02-20 14:09:40 +0100 |
commit | 4b436755d5895cb7113bee135d451cdeb2cf465a (patch) | |
tree | e198bfeebefd1e8e1252bd05b049d8c3ec13b5f2 /src/commands.rs | |
parent | e0d33dae2f2ab70b936467590284030d759f9db7 (diff) | |
download | ntw-4b436755d5895cb7113bee135d451cdeb2cf465a.tar.gz ntw-4b436755d5895cb7113bee135d451cdeb2cf465a.tar.bz2 |
Assert maximum size for command request and response structs
The request and response structs for a command should not be bigger than
the buffer they are read from or written to. Therefore we add
assertions that enforce this property at compile time.
Diffstat (limited to 'src/commands.rs')
-rw-r--r-- | src/commands.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/commands.rs b/src/commands.rs index 99e049f..66851c1 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -34,6 +34,8 @@ struct GetStatusResponse { config_delete_user_password: u8, } +assert_maximum_size!(GetStatusResponse; GetStatusResponse, crate::device::RESPONSE_DATA_LEN); + #[derive(Debug, Default)] struct GetStatusCommand {} @@ -53,11 +55,15 @@ struct ReadSlotNameRequest { internal_slot_number: u8, } +assert_maximum_size!(ReadSlotNameRequest; ReadSlotNameRequest, crate::device::REQUEST_DATA_LEN); + #[derive(Debug, Default, Serialize)] struct ReadSlotNameResponse { slot_name: [u8; 15], } +assert_maximum_size!(ReadSlotNameResponse; ReadSlotNameResponse, crate::device::RESPONSE_DATA_LEN); + #[derive(Debug, Default)] struct ReadSlotNameCommand {} |