Skip to content

Commit

Permalink
Merge pull request #13 from strict-types/fix/counting-reader
Browse files Browse the repository at this point in the history
Fix counting reader: limit must be inclusive
  • Loading branch information
dr-orlovsky authored Apr 28, 2023
2 parents f3e32e8 + db605e8 commit 40bf7b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rust/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<R: io::Read> io::Read for CountingReader<R> {
let len = self.reader.read(buf)?;
match self.count.checked_add(len) {
None => return Err(io::ErrorKind::OutOfMemory.into()),
Some(len) if len >= self.limit => return Err(io::ErrorKind::InvalidInput.into()),
Some(len) if len > self.limit => return Err(io::ErrorKind::InvalidInput.into()),
Some(len) => self.count = len,
};
Ok(len)
Expand Down

0 comments on commit 40bf7b4

Please sign in to comment.