aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-17 22:44:00 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-18 00:00:59 +0200
commit26d0fed1bc2201955ff0138f0ba9f7c5b23e15eb (patch)
tree266c606ca4fe3b45a50ed864c044ee3054c43c52 /lib
parentde6e989cd3634ee783d47f8ec2caac8d16c77436 (diff)
downloadtools.nes-26d0fed1bc2201955ff0138f0ba9f7c5b23e15eb.tar.gz
tools.nes-26d0fed1bc2201955ff0138f0ba9f7c5b23e15eb.zip
Fix shift overflow on certain expressions
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à <mikisabate@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/xixanta/src/assembler.rs4
1 files 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,