aboutsummaryrefslogtreecommitdiff
path: root/core/encoding/varint/leb128.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-03-08 19:56:42 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-03-08 19:56:42 +0100
commit2a41814985f99d76ca07b48896eb79a1e2b4dea9 (patch)
treeb8998b48b0386e9fe30682058b2d2f82316833f5 /core/encoding/varint/leb128.odin
parent26ffec845ba0212e838657320ac70ab464b2bd3e (diff)
[varint] Tighten max input bounds.
Diffstat (limited to 'core/encoding/varint/leb128.odin')
-rw-r--r--core/encoding/varint/leb128.odin4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/encoding/varint/leb128.odin b/core/encoding/varint/leb128.odin
index 898c6af67..476b9c2c9 100644
--- a/core/encoding/varint/leb128.odin
+++ b/core/encoding/varint/leb128.odin
@@ -32,7 +32,7 @@ decode_uleb128 :: proc(buf: []u8) -> (val: u128, size: int, err: Error) {
size = i + 1
// 18 * 7 bits = 126, which means that a possible 19th byte may at most be 0b0000_0011.
- if size == LEB128_MAX_BYTES && v > 0b0000_0011 {
+ if size > LEB128_MAX_BYTES || size == LEB128_MAX_BYTES && v > 0b0000_0011 {
return 0, 0, .Value_Too_Large
}
@@ -64,7 +64,7 @@ decode_ileb128 :: proc(buf: []u8) -> (val: i128, size: int, err: Error) {
size += 1
// 18 * 7 bits = 126, which including sign means we can have a 19th byte.
- if size == LEB128_MAX_BYTES && v > 0x7f {
+ if size > LEB128_MAX_BYTES || size == LEB128_MAX_BYTES && v > 0x7f {
return 0, 0, .Value_Too_Large
}