Skip to content

Commit

Permalink
fix: optimise with constant time fn
Browse files Browse the repository at this point in the history
Signed-off-by: bwty <[email protected]>
  • Loading branch information
whalelephant committed Apr 16, 2021
1 parent ea2132e commit 1a73b85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/interledger-packet/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ impl TryFrom<BytesMut> for Prepare {
let mut expires_at = [0x00; 17];
content.read_exact(&mut expires_at)?;

if !expires_at.iter().all(|e| (b'0'..=b'9').contains(e)) {
if !expires_at
.iter()
.map(|e| (b'0'..=b'9').contains(e))
.fold(true, |a, b| a & b)
{
return Err(ParseError::InvalidPacket("DateTime must be numeric".into()));
}

Expand Down

0 comments on commit 1a73b85

Please sign in to comment.