From f404445003e0530c573ccfca53b63fd0ef873153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 6 Oct 2020 12:39:39 +0200 Subject: [PATCH] deny direct access to symmed register - prevents bugs --- crsn/src/asm/parse/parse_data.rs | 17 +++++++++++++++-- crsn/src/builtin/parse.rs | 2 +- crsn_screen/src/exec.rs | 4 ++-- crsn_screen/src/parse.rs | 2 +- crsn_stacks/src/exec.rs | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/crsn/src/asm/parse/parse_data.rs b/crsn/src/asm/parse/parse_data.rs index 56bc250..8b9bbf4 100644 --- a/crsn/src/asm/parse/parse_data.rs +++ b/crsn/src/asm/parse/parse_data.rs @@ -95,12 +95,25 @@ pub fn parse_data_disp(tok: Option, pcx: &ParserContext) -> Result { diff --git a/crsn/src/builtin/parse.rs b/crsn/src/builtin/parse.rs index a75f3dd..779bea6 100644 --- a/crsn/src/builtin/parse.rs +++ b/crsn/src/builtin/parse.rs @@ -8,7 +8,7 @@ use crate::asm::parse::arg_parser::TokenParser; use crate::asm::parse::parse_data::{parse_constant_name, parse_label, parse_rd, parse_reg_alias, parse_value, parse_label_str}; use crate::asm::parse::sexp_expect::expect_string_atom; use crate::builtin::defs::{Barrier, BuiltinOp}; -use crate::module::{CrsnExtension, ParseRes}; +use crate::module::{ParseRes}; use crate::utils::A; diff --git a/crsn_screen/src/exec.rs b/crsn_screen/src/exec.rs index b29da42..1afd177 100644 --- a/crsn_screen/src/exec.rs +++ b/crsn_screen/src/exec.rs @@ -168,8 +168,8 @@ impl OpTrait for ScreenOp { let xval = xf.round() as u64; let yval = yf.round() as u64; - state.write(*x, xval); - state.write(*y, yval); + state.write(*x, xval)?; + state.write(*y, yval)?; } } } diff --git a/crsn_screen/src/parse.rs b/crsn_screen/src/parse.rs index 1d10887..ea1afe2 100644 --- a/crsn_screen/src/parse.rs +++ b/crsn_screen/src/parse.rs @@ -1,4 +1,4 @@ -use crsn::asm::data::{Rd, RdData}; +use crsn::asm::data::{Rd}; use crsn::asm::error::CrsnError; use crsn::asm::instr::op::OpKind; use crsn::asm::parse::arg_parser::TokenParser; diff --git a/crsn_stacks/src/exec.rs b/crsn_stacks/src/exec.rs index 1d29106..2a6cdc9 100644 --- a/crsn_stacks/src/exec.rs +++ b/crsn_stacks/src/exec.rs @@ -66,7 +66,7 @@ pub(crate) fn drop_obj(state: &mut RunState, handle: Value) -> Result Ok(stacks.store.remove(&handle).map(|_| ())) } -fn prepare_push(mut state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnce(&mut VecDeque, Value) -> ()) -> Result<(), Fault> { +fn prepare_push(state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnce(&mut VecDeque, Value) -> ()) -> Result<(), Fault> { state.clear_status(); let handle = state.read_obj(*obj)?; let val = state.read(*src)?;