mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 22:58:18 +00:00
Error on wasmer validate if the provided file is not wasm. Fix #2477
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::store::StoreOptions;
|
||||
use anyhow::{Context, Result};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
use wasmer::*;
|
||||
@@ -24,6 +24,9 @@ impl Validate {
|
||||
fn inner_execute(&self) -> Result<()> {
|
||||
let (store, _engine_type, _compiler_type) = self.store.get_store()?;
|
||||
let module_contents = std::fs::read(&self.path)?;
|
||||
if !is_wasm(&module_contents) {
|
||||
bail!("`wasmer validate` only validates WebAssembly files");
|
||||
}
|
||||
Module::validate(&store, &module_contents)?;
|
||||
eprintln!("Validation passed for `{}`.", self.path.display());
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user