Skip to content
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

feat(runtime-c-api) Check buffer size before creating the slice, and fix wasmer_last_error_message returned value #432

Merged
merged 6 commits into from
May 13, 2019

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented May 10, 2019

It's safer to check the buffer size is large enough to hold the error
message before creating the slice from raw parts.

Also, this patch remove the need for last_error, simplifying the
code a little bit. The length variable is casted to usize once.

This patch also updates the returned value of wasmer_last_error_message by adding 1, so that it mimics the wasmer_last_error_length function that counts the trailing null byte.

It's safer to check the buffer size is large enough to hold the error
message before creating the slice from raw parts.

Also, this patch remove the need for `last_error`, simplifying the
code a little bit. The `length` variable is casted to `usize` once.
@Hywan Hywan added 🎉 enhancement New feature! 📦 lib-c-api About wasmer-c-api labels May 10, 2019
@Hywan Hywan requested a review from bjfish May 10, 2019 13:58
@Hywan
Copy link
Contributor Author

Hywan commented May 10, 2019

bors try

bors bot added a commit that referenced this pull request May 10, 2019
Returning the error message's length + 1 mimics the
`wasmer_last_error_length` function that counts the trailing null
byte.
@Hywan
Copy link
Contributor Author

Hywan commented May 10, 2019

bors try

@bors
Copy link
Contributor

bors bot commented May 10, 2019

try

Already running a review

@Hywan Hywan changed the title feat(runtime-c-api) Check buffer size before creating the slice [WIP] feat(runtime-c-api) Check buffer size before creating the slice May 10, 2019
@bors
Copy link
Contributor

bors bot commented May 10, 2019

@Hywan
Copy link
Contributor Author

Hywan commented May 10, 2019

I'm not sure about the last patch. I want to write a small test suite before merging.

@Hywan Hywan changed the title [WIP] feat(runtime-c-api) Check buffer size before creating the slice feat(runtime-c-api) Check buffer size before creating the slice May 13, 2019
@Hywan
Copy link
Contributor Author

Hywan commented May 13, 2019

bors r+

bors bot added a commit that referenced this pull request May 13, 2019
432: feat(runtime-c-api) Check buffer size before creating the slice r=Hywan a=Hywan

It's safer to check the buffer size is large enough to hold the error
message before creating the slice from raw parts.

Also, this patch remove the need for `last_error`, simplifying the
code a little bit. The `length` variable is casted to `usize` once.

This patch also updates the returned value of `wasmer_last_error_message` by adding 1, so that it mimics the `wasmer_last_error_length` function that counts the trailing null byte.

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@Hywan
Copy link
Contributor Author

Hywan commented May 13, 2019

bors r-

@bors
Copy link
Contributor

bors bot commented May 13, 2019

Canceled

@Hywan Hywan changed the title feat(runtime-c-api) Check buffer size before creating the slice feat(runtime-c-api) Check buffer size before creating the slice, and fix wasmer_last_error_message returned value May 13, 2019
@Hywan
Copy link
Contributor Author

Hywan commented May 13, 2019

bors r+

bors bot added a commit that referenced this pull request May 13, 2019
432: feat(runtime-c-api) Check buffer size before creating the slice, and fix `wasmer_last_error_message` returned value r=Hywan a=Hywan

It's safer to check the buffer size is large enough to hold the error
message before creating the slice from raw parts.

Also, this patch remove the need for `last_error`, simplifying the
code a little bit. The `length` variable is casted to `usize` once.

This patch also updates the returned value of `wasmer_last_error_message` by adding 1, so that it mimics the `wasmer_last_error_length` function that counts the trailing null byte.

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@bors
Copy link
Contributor

bors bot commented May 13, 2019

@bors bors bot merged commit b050144 into wasmerio:master May 13, 2019
bors bot added a commit that referenced this pull request Aug 19, 2019
693: Bump cc from 1.0.38 to 1.0.40 r=Hywan a=dependabot-preview[bot]

Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.38 to 1.0.40.
<details>
<summary>Commits</summary>

- [`6ad3da7`](rust-lang/cc-rs@6ad3da7) Bump to 1.0.40
- [`9fcdab9`](rust-lang/cc-rs@9fcdab9) Fix a bad merge typo
- [`fa98eb0`](rust-lang/cc-rs@fa98eb0) Bump to 1.0.39
- [`0187762`](rust-lang/cc-rs@0187762) Add CUDA support for MSVC ([#426](https://github-redirect.dependabot.com/alexcrichton/cc-rs/issues/426))
- [`5c0dc67`](rust-lang/cc-rs@5c0dc67) Merge pull request [#433](https://github-redirect.dependabot.com/alexcrichton/cc-rs/issues/433) from turboladen/feature/config-ios-version-min
- [`f99a424`](rust-lang/cc-rs@f99a424) Merge pull request [#432](https://github-redirect.dependabot.com/alexcrichton/cc-rs/issues/432) from BaoshanPang/master
- [`5ab556e`](rust-lang/cc-rs@5ab556e) use wr-c++ instead of vx-cxx
- [`bae28ef`](rust-lang/cc-rs@bae28ef) Detect and use `IPHONEOS_DEPLOYMENT_TARGET` for the `-mi*os-version-min` flag
- [`13e04b1`](rust-lang/cc-rs@13e04b1) Merge pull request [#430](https://github-redirect.dependabot.com/alexcrichton/cc-rs/issues/430) from laanwj/2019_08_rv_nopic
- [`c7cd5dd`](rust-lang/cc-rs@c7cd5dd) Merge pull request [#429](https://github-redirect.dependabot.com/alexcrichton/cc-rs/issues/429) from laanwj/2019_08_rv_correct_abi
- Additional commits viewable in [compare view](rust-lang/cc-rs@1.0.38...1.0.40)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=cc&package-manager=cargo&previous-version=1.0.38&new-version=1.0.40)](https://dependabot.com/compatibility-score.html?dependency-name=cc&package-manager=cargo&previous-version=1.0.38&new-version=1.0.40)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

**Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com).

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature! 📦 lib-c-api About wasmer-c-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants