deny direct access to symmed register - prevents bugs

floats
Ondřej Hruška 4 years ago
parent 2fa23dbbc3
commit f404445003
  1. 17
      crsn/src/asm/parse/parse_data.rs
  2. 2
      crsn/src/builtin/parse.rs
  3. 4
      crsn_screen/src/exec.rs
  4. 2
      crsn_screen/src/parse.rs
  5. 2
      crsn_stacks/src/exec.rs

@ -95,12 +95,25 @@ pub fn parse_data_disp(tok: Option<Sexp>, pcx: &ParserContext) -> Result<DataDis
if let Some(val) = pstate.reg_aliases.get(reference) {
Ok(DataDisp::ObjectPtr(*val))
} else {
Ok(DataDisp::ObjectPtr(reg::parse_reg(reference)?))
let reg = reg::parse_reg(reference)?;
if pstate.reg_aliases.values().find(|v| **v == reg).is_some() {
Err(CrsnError::Parse(format!("Sym exists for register {}, direct access denied. Unsym it if needed.", reg).into()))
} else {
Ok(DataDisp::ObjectPtr(reg))
}
}
} else if s.starts_with(|c: char| c.is_ascii_digit()) {
Ok(DataDisp::Immediate(unsafe { std::mem::transmute(parse_i64(s)?) }))
} else {
Ok(DataDisp::Register(reg::parse_reg(s)?))
let reg = reg::parse_reg(s)?;
let pstate = pcx.state.borrow();
if pstate.reg_aliases.values().find(|v| **v == reg).is_some() {
Err(CrsnError::Parse(format!("Sym exists for register {}, direct access denied. Unsym it if needed.", reg).into()))
} else {
Ok(DataDisp::Register(reg))
}
}
}
_ => {

@ -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;

@ -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)?;
}
}
}

@ -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;

@ -66,7 +66,7 @@ pub(crate) fn drop_obj(state: &mut RunState, handle: Value) -> Result<Option<()>
Ok(stacks.store.remove(&handle).map(|_| ()))
}
fn prepare_push(mut state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnce(&mut VecDeque<Value>, Value) -> ()) -> Result<(), Fault> {
fn prepare_push(state: &mut RunState, obj: &RdObj, src: &Rd, pushfn : impl FnOnce(&mut VecDeque<Value>, Value) -> ()) -> Result<(), Fault> {
state.clear_status();
let handle = state.read_obj(*obj)?;
let val = state.read(*src)?;

Loading…
Cancel
Save