Currently we don't actually sandbox the memory at all, so you can do evil things like read and write the host's memory. We also don't support growing memory or cranelift-compatible ABI that passes the memory offset as an argument. We also always immediately allocate the buffer when encountering a memory section, there is preliminary support for translating a buffer which can then have the real offset replaced using relocations (and returning a different type when doing so) but I haven't written the code that actually does relocation so it doesn't work yet.
34 lines
764 B
Rust
34 lines
764 B
Rust
use capstone;
|
|
use wasmparser::BinaryReaderError;
|
|
|
|
#[derive(Fail, PartialEq, Eq, Clone, Debug)]
|
|
pub enum Error {
|
|
#[fail(display = "Disassembler error: {}", _0)]
|
|
Disassembler(String),
|
|
|
|
#[fail(display = "Assembler error: {}", _0)]
|
|
Assembler(String),
|
|
|
|
#[fail(display = "Input error: {}", _0)]
|
|
Input(String),
|
|
}
|
|
|
|
impl From<BinaryReaderError> for Error {
|
|
fn from(e: BinaryReaderError) -> Self {
|
|
let BinaryReaderError { message, offset } = e;
|
|
Error::Input(format!("At wasm offset {}: {}", offset, message))
|
|
}
|
|
}
|
|
|
|
impl From<!> for Error {
|
|
fn from(other: !) -> Self {
|
|
other
|
|
}
|
|
}
|
|
|
|
impl From<capstone::Error> for Error {
|
|
fn from(e: capstone::Error) -> Self {
|
|
Error::Disassembler(e.to_string())
|
|
}
|
|
}
|