Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Nov 6, 2023
1 parent e1d496f commit 592ae31
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sdk/src/types/block/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ impl<Flag: CapabilityFlag> Capabilities<Flag> {
if bytes.last().map(|b| *b == 0).unwrap_or_default() {
return Err(Error::TrailingCapabilityBytes);
}
// Check if the bytes are valid instances of the flag type.
for (index, &byte) in bytes.iter().enumerate() {
// Get the max value of the flags at this index
let mut b = 0;
for flag in Flag::all().filter(|f| f.index() == index) {
b |= flag.as_byte();
}
// Check whether the byte contains erroneous bits by using the max value as a mask
if b | byte != b {
return Err(Error::InvalidCapabilityByte { index, byte });
}
Expand Down

0 comments on commit 592ae31

Please sign in to comment.