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

rustls_error can cause undefined behavior when a non-error is passed #152

Closed
jsha opened this issue Oct 16, 2021 · 1 comment
Closed

rustls_error can cause undefined behavior when a non-error is passed #152

jsha opened this issue Oct 16, 2021 · 1 comment

Comments

@jsha
Copy link
Collaborator

jsha commented Oct 16, 2021

Steps to reproduce:

  char buf[256];
  size_t n;
  fprintf(stderr, "watch this:\n");
  rustls_error(0, buf, sizeof(buf), &n);

Result:

watch this:
Segmentation fault (core dumped)

This is because it's undefined behavior in Rust to have an enum where the contents are out of range for the enum definition, and there's no rustls_result corresponding to 0.

To fix this, we need to do some validation any time we accept a rustls_result from C. I think that's just in rustls_error.

@jsha
Copy link
Collaborator Author

jsha commented Nov 9, 2021

Fixed in #195

@jsha jsha closed this as completed Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant