From 01f709aa8101ec942498219bed9a583c840c83d0 Mon Sep 17 00:00:00 2001 From: Christian Lewe Date: Sat, 2 Dec 2023 08:58:09 +0100 Subject: [PATCH] Human encoding: Words are <= 2^31 bits long Words are <= 32 levels deep. Depth n means a bit length of 2^{n - 1}. 1 << 32 also causes an overflow on 32-bit systems. --- src/human_encoding/parse/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/human_encoding/parse/ast.rs b/src/human_encoding/parse/ast.rs index ce04a3d9..cd73e0d9 100644 --- a/src/human_encoding/parse/ast.rs +++ b/src/human_encoding/parse/ast.rs @@ -642,7 +642,7 @@ fn grammar() -> Grammar> { let (data, bit_length, position) = toks[1].expect_literal(); let mut iter = BitIter::from(data); - if bit_length.count_ones() != 1 || bit_length > 1 << 32 { + if bit_length.count_ones() != 1 || bit_length > 1 << 31 { return Ast::Error(ErrorSet::single( position, Error::BadWordLength { bit_length },