Repository navigation
Improve handling of errors - #227
Merged
Merged
Conversation
There were still three places where we could have undefined behavior if C gave us an invalid rustls_result: - rustls_result_is_cert_error took a rustls_result as a parameter. - The callback for server certificate validation returned rustls_result. - The callbacks for session storage returned rustls_result. Change all of these to use u32 and the try_from implementation. Fix the comment for the session storage callbacks, which indicated the wrong error strategy. Remove result_to_error in favor of directly implementing Display on rustls_result. This fixes an issue where CertInvalidData was turned into Either::String rather than Either::Error, which caused rustls_result_is_cert_error to (incorrectly) say it wasn't a cert error. This PR also removes the Either struct and the From impls on it.
kevinburke
reviewed
Nov 14, 2021
| } | ||
| } | ||
|
|
||
| /// For cert-related resutl_results, turn them into a rustls::Error. For other |
kevinburke
reviewed
Nov 15, 2021
| CorruptMessagePayload => write!(f, "received corrupt message"), | ||
|
|
||
| PeerIncompatibleError => write!(f, "peer is incompatible"), | ||
| PeerMisbehavedError => write!(f, "peer is incompatible"), |
Contributor
|
Looks OK to me, should we update the changelog now vs. later? |
Collaborator
Author
|
We should update the CHANGELOG as part of the PR - I'll push a commit with that later on. |
Member
|
Seems okay to me. |
djc
approved these changes
Nov 15, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were still three places where we could have undefined behavior if
C gave us an invalid rustls_result:
rustls_result.
Change all of these to use u32 and the try_from implementation.
Fix the comment for the session storage callbacks, which indicated the
wrong error strategy.
Remove result_to_error in favor of directly implementing Display on
rustls_result. This fixes an issue where CertInvalidData was turned into
Either::String rather than Either::Error, which caused
rustls_result_is_cert_error to (incorrectly) say it wasn't a cert error.
This PR also removes the Either struct and the From impls on it.
Fixes #226