-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[examples] Should check import types #129
Comments
This seems to be a bug with Wasmtime's implementation of the C API, not the C API definition itself (this repo). Can you please file it against Wasmtime? |
Did make it originally for wasmtime :) I'll reopen that @yurydelendik. |
The snippet from wasmtime is irrelevant for the issue: here is v8 related snippet: Lines 2036 to 2062 in b0b4bfb
|
I updated the initial description also to apply to this repo. |
Seems risky to rely on caller-only for ensuring that imports match. Would be good to update examples to include such validation. E.g. Lines 111 to 116 in 7865f7d
I didn't spot import validation in the examples I looked through. module would commonly be a file on disk - and if that was changed - it can cause undefined behavior/crashing - unless there is code to catch the mismatch. |
Well, that's how C works just about everywhere. There is no safety in C. But fair point about the examples, they aren't as defensive as they should be in the real world. I changed the subject of this issue to reflect that as a todo. |
For what it's worth, I filed a similar issue (#104) when I first encountered the C API, but I've come around that adding a size argument would be redundant as it must always match the length of the module's imports and it isn't guaranteed in C to accurately describe the array being passed in anyway. |
The wasm_instance_new C-API implementation fails due to buffer overrun for the imports buffer.
The imports argument doesn't have a size.
wasm-c-api/src/wasm-c.cc
Lines 995 to 1006 in b0b4bfb
Since there is no size given as argument, it needs to be assumed that the imports buffer is NULL terminated. Note that all C-API examples need to be updated to add the NULL as the last item for the imports buffer.
The text was updated successfully, but these errors were encountered: