From b81460829a73fa83f679674c9a3bf50fc4862bc1 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 22 Aug 2023 13:54:02 -0700 Subject: [PATCH] Fix range end checks, range end can be the same with data length because the end bracket is open --- tlsn/tlsn-core/src/substrings/proof.rs | 4 ++-- tlsn/tlsn-core/src/transcript.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tlsn/tlsn-core/src/substrings/proof.rs b/tlsn/tlsn-core/src/substrings/proof.rs index ec3e051ff5..f726631c8c 100644 --- a/tlsn/tlsn-core/src/substrings/proof.rs +++ b/tlsn/tlsn-core/src/substrings/proof.rs @@ -68,14 +68,14 @@ impl SubstringsProof { for comm in self.inclusion_proof.commitments().iter() { if comm.direction() == &Direction::Sent { for r in comm.ranges() { - if r.end >= header.sent_len() { + if r.end > header.sent_len() { return Err(Error::ValidationError); } } } else { // comm.direction() == &Direction::Received for r in comm.ranges() { - if r.end >= header.recv_len() { + if r.end > header.recv_len() { return Err(Error::ValidationError); } } diff --git a/tlsn/tlsn-core/src/transcript.rs b/tlsn/tlsn-core/src/transcript.rs index 3e0a977d28..0162f2940e 100644 --- a/tlsn/tlsn-core/src/transcript.rs +++ b/tlsn/tlsn-core/src/transcript.rs @@ -44,7 +44,7 @@ impl Transcript { let mut dst: Vec = Vec::new(); for r in ranges { - if r.end as usize >= self.data.len() { + if r.end as usize > self.data.len() { // range bounds must be within `src` length return Err(Error::InternalError); } else {