From 26d0fed1bc2201955ff0138f0ba9f7c5b23e15eb Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 17 Aug 2025 22:44:00 +0200 Subject: Fix shift overflow on certain expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I got a report from libfuzz that some cryptic input could make the assembler panic on shifts. It turns out that the check on whether the operator was too big or not had to be explicitely casted to `usize` to avoid signedness issues. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 6fc0cc1..26d5396 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -970,7 +970,7 @@ impl<'a> Assembler<'a> { lval ^ rval } OperationType::Lshift => { - if rval > 16 { + if rval as usize > 16 { return Err(Error { line: node.value.line, global: false, @@ -983,7 +983,7 @@ impl<'a> Assembler<'a> { lval << rval } OperationType::Rshift => { - if rval > 16 { + if rval as usize > 16 { return Err(Error { line: node.value.line, global: false, -- cgit v1.2.3