@@ -117,26 +117,16 @@ libwasmtime_exec (void *cookie, libcrun_container_t *container arg_unused,
117
117
wasm = wasm_bytes ;
118
118
}
119
119
120
- // Check if it is a valid webassembly module or
121
- // a component.
122
- bool is_wasm_module = true;
123
- wasmtime_error_t * err = wasmtime_module_validate (engine , (uint8_t * ) wasm .data , wasm .size );
124
- if (err != NULL )
125
- {
126
- wasmtime_error_message (err , & error_message );
127
- wasmtime_error_delete (err );
128
-
129
- if (strcmp ((char * ) error_message .data , "component passed to module validation" ) != 0 )
130
- error (EXIT_FAILURE , 0 , "failed to validate module: %.*s" , (int ) error_message .size , error_message .data );
120
+ wasm_encoding_t wasm_enc = wasm_interpete_header (wasm .data );
121
+ if (wasm_enc == WASM_ENC_INVALID )
122
+ error (EXIT_FAILURE , 0 , "invalid wasm binary header" );
131
123
132
- err = NULL ;
133
- is_wasm_module = false;
134
- }
135
-
136
- if (is_wasm_module )
124
+ if (wasm_enc == WASM_ENC_MODULE )
137
125
libwasmtime_run_module (cookie , argv , engine , & wasm );
138
- else
126
+ else if ( wasm_enc == WASM_ENC_COMPONENT )
139
127
libwasmtime_run_component (cookie , argv , engine , & wasm );
128
+ else
129
+ error (EXIT_FAILURE , 0 , "unsupport wasm encoding detected" );
140
130
141
131
exit (EXIT_SUCCESS );
142
132
}
0 commit comments