From 3dd43311506ad786d5acc651906491fe90d9237e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 2 Aug 2024 18:01:36 +0100 Subject: [PATCH] fix underflow subtraction on read_unknown --- quick-protobuf/src/reader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-protobuf/src/reader.rs b/quick-protobuf/src/reader.rs index 85ebdd6..7420eb1 100644 --- a/quick-protobuf/src/reader.rs +++ b/quick-protobuf/src/reader.rs @@ -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;