Skip to content

Commit

Permalink
fix underflow subtraction on read_unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Aug 2, 2024
1 parent 54e7d6c commit 3dd4331
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion quick-protobuf/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl BytesReader {
// Meant to prevent overflowing. Comparison used is *strictly* lesser
// since `self.end` is given by `len()`; i.e. `self.end` is 1 more than
// highest index
if self.end - self.start < offset {
if self.end.checked_sub(self.start).ok_or(Error::Varint)? < offset {
Err(Error::Varint)
} else {
self.start += offset;
Expand Down

0 comments on commit 3dd4331

Please sign in to comment.