Skip to content

Commit

Permalink
policy: fix the incorrect logic comparing array
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Jan 5, 2024
1 parent e3bcabc commit 5dbe3e5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/policy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,14 @@ fn parse_range(input: &str) -> Option<ops::Range<usize>> {
pub(crate) struct Array(Vec<u8>);

impl Array {
fn verify(&self, is_src: bool, op: &Operation, _local: &[u8], peer: &[u8]) -> bool {
fn verify(&self, _is_src: bool, op: &Operation, _local: &[u8], peer: &[u8]) -> bool {
if peer.len() != self.0.len() {
return false;
}

match op {
Operation::ArrayEqual => self.0.as_slice() == peer,
Operation::ArrayGreaterOrEqual => {
self.0
.iter()
.zip(peer.iter())
.all(|(r, p)| if is_src { p >= r } else { r >= p })
}
Operation::ArrayGreaterOrEqual => self.0.iter().zip(peer.iter()).all(|(r, p)| p >= r),
_ => false,
}
}
Expand Down

0 comments on commit 5dbe3e5

Please sign in to comment.